Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在cmd中手动运行命令会产生与Python不同的结果_Python_Windows_Cmd - Fatal编程技术网

在cmd中手动运行命令会产生与Python不同的结果

在cmd中手动运行命令会产生与Python不同的结果,python,windows,cmd,Python,Windows,Cmd,在Windows中,我有一个命令Bubbles.scr/s,当输入任何目录下的cmd终端时,它会毫无问题地启动“Bubbles”屏幕保护程序。我正试图通过以下方式使用Python实现这一点: import os os.system("Bubbles.scr/s") 但是我收到了错误 'Bubbles.scr' is not recognized as an internal or external command, operable program or batch fil

在Windows中,我有一个命令
Bubbles.scr/s
,当输入任何目录下的cmd终端时,它会毫无问题地启动“Bubbles”屏幕保护程序。我正试图通过以下方式使用Python实现这一点:

import os
os.system("Bubbles.scr/s")
但是我收到了错误

'Bubbles.scr' is not recognized as an internal or external command,
operable program or batch file.
这里有什么问题?它是否与
Bubbles.scr
位于
C:\Windows\System32
目录中这一事实有关


提前谢谢

path有问题,因为当您打开cmd时,屏幕保护程序所在的路径(即system32)被添加到系统变量中,因此它可以完美地执行,但当您执行python脚本时,路径被设置为当前目录,因此它找不到Bubbles.scr。除了路径之外,您的代码正常。以下代码工作:

import os
os.system("C:\Windows\System32\Bubbles.scr /s")

path有一个问题,因为当您打开cmd时,屏幕保护程序所在的路径(即system32)被添加到系统变量中,因此它可以完美地执行,但是当您执行python脚本时,该路径被设置为当前目录,因此它找不到Bubbles.scr。除了路径之外,您的代码是正常的。以下代码可以工作:

import os
os.system("C:\Windows\System32\Bubbles.scr /s")

所以我以前试过这个,但对我不起作用。我发现错误
'C:\Windows\System32\Bubbles.scr'未被识别为内部或外部命令、可操作程序或批处理文件。
能否添加一个屏幕截图,因为它对我有效。我在第一条评论中收到错误消息。我认为这与
SysWOW64
目录有关,但我不知道。您使用的是什么版本的windows r,您是否尝试过我的代码,因为它对我有效,以及您使用的是哪个版本的python?请使用路径,
where bubbles.scr
为您提供的路径。因此,我以前尝试过这个,但对我无效。我发现错误
'C:\Windows\System32\Bubbles.scr'未被识别为内部或外部命令、可操作程序或批处理文件。
能否添加一个屏幕截图,因为它对我有效。我在第一条评论中收到错误消息。我认为这与
SysWOW64
目录有关,但我不知道。您使用的是什么版本的windows r,您是否尝试过我的代码,因为它对我有用,以及您使用的是哪个版本的python?请使用路径,
where bubbles.scr
为您提供的路径。