简体   繁体   English

如何使用python编写不包含空字节字符的字符串

[英]How to write string not containing null byte character using python

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

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

Just replace '\\x00' your input string by an empty character.只需用空字符替换'\\x00'您的输入字符串。

In your example that would look like this :在您的示例中,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM