【问题标题】:How to write string not containing null byte character using python如何使用python编写不包含空字节字符的字符串
【发布时间】:2018-02-16 12:00:25
【问题描述】:

如何在文件中写入字符串以确保python中的字符串中没有空字节字符?

f.write(x1+','+x2+','+x3)

【问题讨论】:

    标签: python string file file-handling nul


    【解决方案1】:

    只需将'\x00' 替换为空字符即可。

    在你的例子中,看起来像这样:

    data = x1+','+x2+','+x3
    data = data.replace('\x00' , '')
    f.write(data)
    

    【讨论】:

      猜你喜欢
      • 2020-06-26
      • 1970-01-01
      • 2012-08-08
      • 2020-02-27
      • 1970-01-01
      • 2018-02-25
      • 1970-01-01
      • 2021-05-30
      • 2011-10-25
      相关资源
      最近更新 更多