【问题标题】:Windows Command Line: CD & Execute Python [closed]Windows 命令行:CD 和执行 Python [关闭]
【发布时间】:2014-06-06 16:27:33
【问题描述】:

我在从 Windows 7 命令提示符执行 python 脚本时遇到问题。我尝试了许多不同的命令来运行脚本。是否:

python e:\filepath\pythonScript.py
python pythonScript.py
cd\ & pythonScript.py
cd\ && e:\filepath\pythonScript.py

我还是一样:

[Errno 2] No such file or directory

每当我使用命令时:

dir

即使我使用它也会打印 c: 驱动器的内容:

cd c: && dir

如果有人能对在 Windows 7 中更改目录和执行 python 脚本有所了解,我将不胜感激。

【问题讨论】:

  • 当你输入“dir”时,你看到你的python脚本了吗?
  • 我看到了脚本所在的目录,但看不到实际文件本身。我得到如下输出:05/02/2012 11:59PM <DIR> Apps,其中列出了大约 7 个目录。

标签: python windows command cd


【解决方案1】:

如果您要更改为新驱动器,只需键入驱动器号,后跟冒号

C:\>e:
E:\>dir


Volume in drive E has no label.
 Volume Serial Number is 9016-4EF8

 Directory of E:\
18-Apr-14  02:16 AM    <DIR>          assets
01-May-14  04:22 AM    <DIR>          store
06-Jun-14  09:32 AM                22 test.py

E:\>cd assets


E:\assets>python test.py
hello world

C:\>e: && cd assets && dir
 Volume in drive E has no label.
 Volume Serial Number is 9016-4EF8

 Directory of E:\assets

  C:\>e: && cd \  && cd assets && dir
       ^     ^          ^           ^
ch drive && go root&&go fldr && list foldr contents

【讨论】:

  • 谢谢!我以为你在驱动器号之前需要cd,但我错了。
猜你喜欢
  • 2014-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-21
  • 2020-09-25
相关资源
最近更新 更多