【问题标题】:How to print correctly in python 3.8 [duplicate]如何在python 3.8中正确打印[重复]
【发布时间】:2021-07-07 04:48:19
【问题描述】:

当我尝试打印如下内容时,它返回了 invalid syntax 之类的错误

我的运行时是python3.8

这哪里错了?

print 'Content: {}'.format(content)

如果有人有意见,请告诉我

谢谢

【问题讨论】:

  • 在 python 3x 中,无论您要打印什么,都需要(),就像这样:print('Content: {}'.format(content))
  • 这能回答你的问题吗? Python3 Print Function

标签: python python-3.x


【解决方案1】:

这看起来非常像 python 2 代码。您需要在打印语句中提供从 python 3 开始的括号

print ('Content: {}'.format(content))

这也可以。

print(f'Content: {content}')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-05
    • 1970-01-01
    • 2017-02-01
    • 2021-05-14
    • 1970-01-01
    • 2021-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多