0#2在Windows下运行Python
2018-08-05 本文已影响0人
淇漯草
第一步,代码结构
在windows下,代码前面加上#! python3
如,我用一个口令保管箱作为项目
#! python3
# pw.py - Aninsecure password locker program.
import pyperclip
PASSWORDS = {'email':'XXXX',
'QQ':'chaojisaiyaren',
'Chinese':'superstar'}
import sys
if len(sys.argv) < 2:
print('Usage: py pw.py [account] - copy account password')
sys.exit()
account = sys.argv[1]
if account in PASSWORDS:
pyperclip.copy(PASSWORDS[account])
print('Password for ' + account + ' copied to clipboard')
else:
print('There is no account named' + account)
上述这个代码的名字叫做 ‘口令保管箱.py’
地址在G:\Python\代码 (一个文件夹中)
第二步,建立一个批文件
根据我的理解,这是一个可以通过命令行或其他的东西的一种方式。
在这里的作用是引导作用
-
建立一个txt文件,输入
@py.exe G:\Python\代码\口令保管箱.py %#
image.png
第三步,添加路径


新建

大功告成,查看结果
Win + R

输入后就成功了。