【问题标题】:How python interpreter giving this output? [duplicate]python解释器如何给出这个输出? [复制]
【发布时间】:2019-08-03 23:48:48
【问题描述】:

当我打印这个时,它给了我这个我不明白的输出如何?

>>> print(1,000,000)
1 0 0

【问题讨论】:

  • 在语法上等价于print(1, 0, 0)
  • 使用逗号,print 需要打印 3 个值。 1 和两个 000s。 000 就是 0。因此输出。
  • 试试print(1_000_000)
  • 尝试像字符串一样打印,例如print('1,000,000')

标签: python


【解决方案1】:

您正在打印 3 个不同的值。和这个一样:

print('Hi', 'hello world', 'bye bye')

而000被解释为0,例如:

print(000000000)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 1970-01-01
    • 2015-03-28
    • 1970-01-01
    • 2012-06-21
    相关资源
    最近更新 更多