我在一个文本文件“program.py”中写了程序。我将这个文件保存在桌面上。我想通过命令行来执行此Python命令行
Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Users\x0266161>cd C:\Users\x0266161\Desktop\
C:\Users\x0266161\Desktop>python program.py
hello world
Now is it possible for me to execute the program without changing to the directory where program is stored.
when I try I am getting below error
C:\Users\x0266161\Desktop>cd ..
C:\Users\x0266161>cd ..
C:\Users>cd ..
C:\>python program.py
python: can't open file 'program.py': [Errno 2] No such file or directory
C:\>
我有环境变量设置为这个路径C:\用户\ x0266161 \桌面。