[英]Cannot print in one line using Python3 and Python2.7
I tried both following ways to print in one line: 我尝试了以下两种方法在一行中进行打印:
print (max,end=' ') # Python3
print max, # Python2.7
However, Pycharm
complains and gives me unresolved reference when using the first one. 但是,
Pycharm
抱怨并在使用第一个参考书时给了我未解决的参考。 When I switch to Python 2.7 Interpreter and use print max,
it gives this error: 当我切换到Python 2.7解释器并使用
print max,
它会出现此错误:
SyntaxError: Missing parentheses in call to 'print'
I don't know what to do!! 我不知道该怎么办!! Appreciate any help.
感谢任何帮助。
Well, first Use 好吧,第一次使用
print(max,...) # NOTE: no space after the word print
The space in your question is being interpreted as print (some_tuple)
or print X
where X
is a tuple, and then it thinks you are trying to use the python2 way of printing. 您问题中的空格被解释为
print (some_tuple)
或print X
,其中X
是一个元组,然后认为您正在尝试使用python2打印方式。
Second, not sure what print(max,end=' ')
is supposed to do, but you can't define a variable in a print statement like that. 其次,不确定
print(max,end=' ')
应该做什么,但是您不能在这样的print语句中定义变量。 What are you trying to print? 您要打印什么?
from __future__ import division
文件顶部的from __future__ import division
执行操作,仅使用Python 3样式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.