Python 3.6.0 语法错误“调用‘打印’时缺少括号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41341149/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python 3.6.0 syntax error "Missing parentheses in call to 'print'
提问by Meme Buddha
I'm a gamer who decided he wanted to make some basic games others could play. I'm very new to coding and have the most basic understanding of it. My cousin and I are trying to make a text based game in Python 3.6.0. We have searched the internet for answers to our problem, but cannot find anything. Code is below:
我是一名游戏玩家,他决定制作一些其他人可以玩的基本游戏。我对编码很陌生,对它有最基本的了解。我和我的堂兄正在尝试用 Python 3.6.0 制作一个基于文本的游戏。我们在互联网上搜索了我们问题的答案,但找不到任何东西。代码如下:
def start ():
print ''' Welcome to the game! Created by Meme Buddha
type 'start' to begin'''
print
prompt_sta ()
def prompt_sta ():
prompt_0 = input ('Type a Command, ')
try:
if prompt_0 == 'Start':
outside_house ()
elif prompt_0 == 'Begin':
print 'You need to drink bleach and look at spicy memes!'
print
prompt_sta ()
else:
print 'Type Start, throw it on him not me,ugh,lets try something else!'
print
prompt_sta ()
except ValueError:
print 'Type Start, throw it on him not me,ugh,lets try something else!'
print
prompt_sta ()
start ()
When trying to run the module to test it, we get an error which says:
在尝试运行模块进行测试时,我们收到一个错误消息:
"Missing parentheses in call to 'print'"
“调用'打印'时缺少括号”
Since we have such a basic knowledge of coding, and couldn't find answers on google, we were hoping that someone could help fix this most likely, simple error.
由于我们对编码有如此基本的了解,并且无法在谷歌上找到答案,我们希望有人能帮助解决这个最有可能的简单错误。
回答by kentwait
This is very basic problem but because you seem completely new to everything...
这是一个非常基本的问题,但因为你对一切似乎都是全新的......
The print
"statement" in Python 3.x is a function that uses parenthesis so:
print
Python 3.x 中的“语句”是一个使用括号的函数,因此:
print "Hello world" # python 2.x
Is now
就是现在
print("Hello world") # python 3.x