[英]Can't get script to run using windows command line with batch file
环境是正确的,但是找不到我的程序。
我的python程序的代码,使用Visual Studio 2017创建,位于以下位置:
C:\\Users\\Alex\\Python Programs\\pw\\pw
。
#! python3
# pw.py - An insecure password locker program.
PASSWORDS = {'email': 'f7nsdkfn2BDD3fkjTXjs6Fjsn',
'blog': 'fdkNc32NskNskKslLI321n',
'luggage': 12345}
import sys, pyperclip
if len(sys.argv) < 2:
print("Usage: python pw.py [account] - copy account password")
sys.exit()
account = sys.argv[1] # first command line arg is the account name
if account in PASSWORDS:
pyperclip.copy(PASSWORDS[account])
print("Password for " + account + " copied to clipboard")
else:
print("There is no account named " + account)
然后,我在这里创建了一个.bat文件: C:\\Users\\Alex\\Python Programs\\pw\\pw
@py.exe C:\Users\Alex\Python Programs\pw\pw\pw.py %*
@pause
我知道环境设置正确,因为我在命令行中输入python时得到了python详细信息。
但是如果我输入:
pw <luggage>
我收到一条错误消息,说The syntax of the command is incorrect
。
如果输入:
python pw
我收到此错误(null): can't open file 'pw': [Errno 2] No such file or directory
。
不知道我做错了什么,现在我花了太多时间在此上。
现在,我将批处理文件更改为runpw,当我双击该文件时,我得到以下消息:-“'py.exe'不被识别为内部或外部命令,可操作程序或批处理文件。”
固定。 我重新整理了文件并将其放置在以下文件夹中:-C:\\ Users \\ Alex \\ Python_programs \\ Password_project
最初在文件路径中包含空格可能是导致此问题的原因。
还要确保您不要将文件另存为pw.py.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.