【问题标题】:How can I make the new python accept print without parentheses?如何让新的 python 接受不带括号的打印?
【发布时间】:2014-09-05 15:05:48
【问题描述】:

有没有办法可以更改我在 python 中的设置以便我可以使用

print "hello world" 代替新的print ("hello world") 而不安装较早的python 包

【问题讨论】:

  • @robbrit:不是真的;他们想在 Python 3 中使用旧的 Python 2 语法。

标签: python printing command


【解决方案1】:

唯一的方法是使用 python2.x 而不是 python3.x。在python3.x中,print是一个函数,没有办法将其转回语句。

但是,有些工具可以转换 大多数 python2 代码以兼容 python3。查看2to3,它通常随 python3 发行版一起提供。

【讨论】:

  • 这就是我害怕的。谢谢
  • 因为有一个同情的耳朵会很有帮助,我同意这是 Python 3 中的一个错误。一致性的大妖精赢得了这一轮。
猜你喜欢
  • 2015-11-14
  • 2017-02-25
  • 2012-03-10
  • 1970-01-01
  • 2013-10-07
  • 2021-11-16
  • 1970-01-01
  • 1970-01-01
  • 2011-10-12
相关资源
最近更新 更多