I'm doing a curl request that returns something like this :
b'{\n "output": {\n id": "11-222-33-44-5abcd6efg"\n }\n}\n'
then I'm doing
id=re.sub("\{.*\: \"", "", output)
id=re.sub("\" *\}.*", "", id)
but i get : TypeError: can't use a string pattern on a bytes-like object
I'd like to convert the output into string maybe it would work then, or if you have any other idea, my goal is to get that id. Doing this in Python
如果g
是您的二进制字符串,则g.decode("utf-8")
将为您提供所要的内容。
In my opinion, you should try
# utf-8 is used here because it is a very common encoding, but you
# need to use the encoding your data is actually in.
output = output.decode('utf-8')
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.