Both patterns and strings to be searched can be Unicode strings (str)
as well as 8-bit strings (bytes). However, Unicode strings and 8-bit
strings cannot be mixed: that is, you cannot match a Unicode string
with a byte pattern or vice-versa; similarly, when asking for a
substitution, the replacement string must be of the same type as both
the pattern and the search string.
正如您所说,
response.content
是一个bytes
,因此regex中的所有参数都必须是byte
类型的,包括替换字符串。在从documentation:
相关问题 更多 >
编程相关推荐