用from __future__ import print_function
# python Python 2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> list =["a", "b", "c"] >>> print list ['a', 'b', 'c'] >>> from __future__ import print_function >>> print (list) ['a', 'b', 'c'] >>>
Python3 与 Python2 的许多兼容性设计的功能可以通过 __future__ 这个包来导入。
参考:
Python 基础语法 | 菜鸟教程
2. 内置函数 — Python 2.7.18 文档



