【问题标题】:I have a problem when i try to use chr python 3我尝试使用 chr python 3 时遇到问题
【发布时间】:2019-12-15 17:14:25
【问题描述】:

我正在使用 vs 代码,当我尝试运行它时: print(str(chr(257))) 我收到此错误:ValueError: chr() arg not in range(256)

【问题讨论】:

  • 你确定是python3而不是python2吗?

标签: python-3.x chr


【解决方案1】:

您似乎正在使用 Python 2 解释器来运行 Python 3 代码。如docs for that function in Python 2.7中所述:

参数必须在 [0..255] 范围内,包括在内;如果 i 超出该范围,将引发 ValueError

将您在 VS Code 中使用的解释器切换为 Python 3 解释器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-23
    • 2015-08-11
    • 2021-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多