-4
在Python 3,我绑到打印一行没有跳过行打印时无效的语法Python中使用“结束”的说法
print('hello', end='')
^
SyntaxError: invalid syntax
发生了什么事?我该如何纠正这个错误?
在Python 3,我绑到打印一行没有跳过行打印时无效的语法Python中使用“结束”的说法
print('hello', end='')
^
SyntaxError: invalid syntax
发生了什么事?我该如何纠正这个错误?
你确定你使用的是Python 3,而不是意外地调用Python 2?
~ $ python3
Python 3.6.2 (default, Jul 17 2017, 16:44:45)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello', end='')
hello>>>
~ $ python2
Python 2.7.13 (default, Jul 18 2017, 09:17:00)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello', end='')
File "<stdin>", line 1
print('hello', end='')
^
SyntaxError: invalid syntax
>>>
请注意,我已经咨询类似的问题没有满意的结果。 –
你确定你没有使用Python 2吗?运行'import sys;打印(sys.version)'并查看它打印出来的内容。发布结果。 –
@vaultah该问题的答案没有解决我的问题。 –