import sys
print(sys.platform)
print(2**100)
raw_input()
Run Code Online (Sandbox Code Playgroud)
我正在使用Python 3.1并且无法raw_input"冻结"dos弹出窗口.我正在阅读的书是Python 2.5,我使用的是Python 3.1
我该怎么做才能解决这个问题?
我正在编写一个必须接受用户输入的程序.
#note: Python 2.7 users should use `raw_input`, the equivalent of 3.X's `input`
age = int(input("Please enter your age: "))
if age >= 18:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
Run Code Online (Sandbox Code Playgroud)
如果用户输入合理数据,这将按预期工作.
C:\Python\Projects> canyouvote.py
Please enter your age: 23
You are able to vote in the United States!
Run Code Online (Sandbox Code Playgroud)
但如果他们犯了错误,那就崩溃了:
C:\Python\Projects> canyouvote.py
Please enter your age: dickety six
Traceback (most recent call last):
File "canyouvote.py", line 1, in …Run Code Online (Sandbox Code Playgroud) 如何创建一个简单的BAT文件来运行位于C:\ somescript.py的python脚本?
非常感谢
我如何在Python中"点击任何键"(或获取菜单选项)?
有没有一种可移植的方法来使用标准库?
我正在python(基于终端)编写一个自己选择冒险的游戏风格游戏,我希望程序暂停打印直到enter按下按钮.这是一个例子.
print("zzzzzzzzz")
Run Code Online (Sandbox Code Playgroud)
进入继续的新闻将来到这里.然后,在他们按下回车后,此块将运行.
print("yyyyyy")
Run Code Online (Sandbox Code Playgroud)
Python 3是首选.