【问题标题】:python behaves differently when run through CMD通过 CMD 运行时,python 的行为有所不同
【发布时间】:2016-05-08 16:49:38
【问题描述】:

当通过 CMD 运行读取二进制文件时,将返回一个字符串而不是 byte_array。 例如:

with open("Image_file", "rb") as f:
    data = f.read(1)
print(type(data))

将返回 str。 当你通过 python IDLE 运行它时,它会返回一个字节数组。 是什么原因造成的?

【问题讨论】:

  • 你也安装了python2,你已经从命令行运行了。
  • 谢谢伙计。我很沮丧。

标签: python-3.x


【解决方案1】:

您也安装了 python2,并且您已经从命令行运行了它。检查您的 python 安装和路径配置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-20
    • 2011-07-12
    • 2021-12-24
    • 1970-01-01
    • 1970-01-01
    • 2014-08-01
    • 2015-07-04
    • 1970-01-01
    相关资源
    最近更新 更多