2017.7.5(转)python2.7,一个困扰了我一天的print问题

来源:互联网 发布:全面战争战锤优化 编辑:程序博客网 时间:2024/06/05 04:36

出处
在python2.7中使用print()时出现错误

print('t',end='\n',)                 ^SyntaxError: invalid syntax。

这是因为在python2中,print只是一个statement。在python3中,才能作为一个function使用。

解决方案:引入print_function。如下:

from __future__ import print_function

注:该import需放在其他import之前。

因为这个问题,下载了python3

阅读全文
0 0