密码保管箱

 》题目要求

  根据用户输入的序号找到对应的登录名称

  将这个登录名称对应的密码自动复制到剪切板中

》程序实现

 1 #!/usr/bin/env python
 2 import pyperclip
 3 information = {
 4     "wifi密码":"1",
 5     "博客园登录名": "2",
 6 }
 7 
 8 information01 = {
 9     "1":"wifi密码",
10     "2":"博客园登录名",
11 }
12 
13 PASSWORDS = {
14     "1":"39322438",
15     "2": "NeverCtrl_C",
16 }
17 
18 PASSWORDS01 = {
19     "wifi密码":"39322438",
20     "博客园登录名": "NeverCtrl_C",
21 }
22 
23 while True:
24     print("NOTICE: The word of name will represent all of account name.")
25     print("Please input the account name("" : quit ):")
26     account = input()
27     if "" == account:
28         break
29     if "name" == account:
30         for k, v in information.items():
31             print(k.ljust(20, ".") + v.rjust(5, "."))
32     if "password" == account:
33         for k, v in PASSWORDS01.items():
34             print(k.ljust(10, ".") + v.rjust(20, "."))
35     if account in PASSWORDS:
36         pyperclip.copy(PASSWORDS[account])
37         print("The content of " + information01.get(account, "哈哈") + " has been copied to clipboard")
38     else:
39         print("There is no content about " + account)
40         print("GO ON".center(60,"="))
View Code

》程序目的

  熟练掌握字典的相关方法的使用:keys() values() items()

  熟练掌握字符串相关方法的使用:ljust() rjust() center() 

  熟练掌握pyperclip.copy() pyperclip.paste()

》程序改进1

  利用批处理文件来执行这个程序

  三少好久没吃火锅啦,已经没有更新的心情啦,所以待更新中......

  》》新建一个文本文档,将后缀改为 .bat ; 在里面书写如下内容

    @python3.exe E:PythonProgrammingMyPythonScripts est.py %*
    @pause

  》》再新建一个文本文档,将后缀改为  .py  ; 在里面书写程序

    》》》注意:编写程序是的 .py 文档最好用 utf-8 格式进行编码

》程序改进2

  怎么实现在DOS中直接输入 .bat 文件名就能执行相应的 .bat文件

  只需要将包含  .bat文件和相应的 .py  文件夹的路径加到系统默认路径即可

原文地址:https://www.cnblogs.com/NeverCtrl-C/p/6130468.html