结尾=》 ”是一个错误
可能的重复:
python print end=' '
你好,我一直在自学 python,但遇到了问题end=“”语句。 有人可以帮助我吗?当我在代码中运行它时,它说这是无效的语法。 提前谢谢。我写错了吗?
非常感谢对新手的帮助。
Possible Duplicate:
python print end=' '
Hello I've been teaching myself python, and I'm having trouble with the end= " " statement.
could anybody help me with it?when i run it in my code it said that is is a invalid syntax.
Thx in advance. Am i writing it wrong?
Help for a newbie is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您在使用
print
语句时遇到问题,因此您尝试使用print(var,end="")
。此语法仅对 Python 3.0 有效。如果您使用的是 Python 2.x,那么它会显示错误。为了了解您正在使用哪个版本的 python,请在终端中输入python --version
。 Python 2.x 和 python 3 在语法上略有不同。您可以在此处阅读它们之间的区别。顺便说一句,在 Python 2.x 中,您可以通过
print var,
获得相同的结果I assume that you are having trouble with
print
statement, So you are trying to useprint(var,end="")
. This syntax is only valid with Python 3.0. if you are using Python 2.x then it will show you an error. In order to know which version of python you are using typepython --version
in your terminal. Python 2.x and python 3 slightly differ in syntax. You can Read the the difference between them here.By the way in Python 2.x you can achieve the same result by
print var,
显然不是作业问题:
因此一定存在另一个问题。由于没有看到错误消息和实际代码,我能提出的唯一建议是:
“ ”
之类的内容。当网页创建者懒得发布正确的代码(或者他们的演示引擎消化它)时,最后一个特别烦人,并且在我的系统上,结果是:
Clearly not a problem with an assignment:
Therefore there must be another issue. Short of seeing the error message and actual code, the only suggestions I can make are:
“ ”
cut'n'pasted from a Word document or web page.That last one is particularly annoying when web page creators can't be bothered posting proper code (or their presentation engines munge it) and, on my system, results in: