简体   繁体   中英

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. When I switch to Python 2.7 Interpreter and use print max, it gives this error:

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.

Second, not sure what print(max,end=' ') is supposed to do, but you can't define a variable in a print statement like that. What are you trying to print?

from __future__ import division文件顶部的from __future__ import division执行操作,仅使用Python 3样式。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM