【发布时间】:2017-10-11 23:57:06
【问题描述】:
enter image description here我正在 Windows XP 中使用 Python 3.4.4。当我双击运行 .py 文件时,它只询问用户名,然后突然终止命令提示符。所以我看不到最终结果。这是我的代码:
from datetime import datetime
import time
from os import getcwd
import sys
name = input("Your name please: ")
print("Hello",name,",your system is:",sys.platform)
print("Your current work directory is:",getcwd())
print("Currenttime:",time.strftime("%a"),datetime.today(),time.strftime("%p"))
print("Thanks for trying. \u00a9 Gaz does Python")
input()
有人可以帮帮我吗?我试过time.sleep(),但也没有用。
【问题讨论】:
-
使用默认 OEM 代码页打印 U+00A9 时,它可能会因编码错误而死。
-
从 cmd shell 运行脚本时是否失败并出现错误?
-
没有错误。它只是提示输入名称,然后像眨眼一样闪烁。如果我仔细观察,我可以看到闪烁时的输出。
-
我的意思是,如果你在 cmd shell(即命令提示符)中切换到目录 (
cd path\to\script) 后以"python script.py"运行它。
标签: windows python-3.x windows-console