在python2.7中使用print()时出现错误
print('t',end='n',)^
SyntaxError: invalid syntax。
这是因为在python2中,print只是一个statement。在python3中,才能作为一个function使用。
解决方案:引入print_function。如下:
from __future__ import print_function
注:该import需放在其他import之前。
最后
以上就是结实抽屉最近收集整理的关于python2.7中print()的使用的全部内容,更多相关python2.7中print()内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复