I'm using Python 2.6 and I have a variable which contains a string (I have sent it thorugh sockets and now I want to do something with it). The problem is that I get the following error:
TypeError: file() argument 1 must be encoded string without NULL bytes, not str
After I looked it up I found out that the problem is probably that the string I'm sending contains '\\0' but it isn't a literal string that I can just edit with double backslash or adding a 'r' before hand, so is there a way to tell python to ignore the escape sequences and treat the whole thing as string?
(For example - I don't want python to treat the sequence \\0 as a null char, but rather I want it to be treated as a backslash char followed by a zero char)
考虑到所有注释,它看起来好像使用了不正确的PIL / Pillow API,即需要文件名而不是文件数据的Image.open
函数。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.