便携式Python无法启动脚本

0 投票
1 回答
1466 浏览
提问于 2025-04-18 08:02

新手问题。

我在试用Portable Python,但我无法通过Python-Portable.exe这个程序加载一个脚本。我是在命令行中运行的:

> Python-Portable.exe hello.py

我想让它加载hello.py,这个文件和可执行程序放在同一个文件夹里,顺便说一下,我也把它放在和真正的python.exe同一个文件夹里。它启动了Portable Python,显示了一个启动画面一秒钟,然后弹出一个控制台窗口,接着立刻关闭。

不过,如果我直接在命令行中启动python.exe,并传入hello.py,它就能正常工作。那么我有两个问题:

为什么使用Python-Portable.exe不行呢?

启动Python-Portable.exe和直接启动Python.exe有什么区别呢?

补充:这是hello.py,它是Portable Python网站上使用的示例。

print("Hello world")

a = True
if a == True:
    print("It is true!")
else:
    print("It is false...")

b = raw_input("Enter value:")
print("Your value is")
print(b)

raw_input("Press enter to continue...")

1 个回答

0

hello.py里有个拼写错误。

写得不好的代码不会被执行,你也得不到任何反馈。

撰写回答