我有问题。
此功能在我的/usr/local/lib/python3.7/re.py
中
def search(pattern, string, flags=0):
"""Scan through string looking for a match to the pattern, returning
a Match object, or None if no match was found."""
return _compile(pattern, flags).search(string)
我在此行中调用此函数:
total = int(re.sub("[',\. ]", "", re.search("(([0-9]+[',\. ])*[0-9]+)", totalText).group(1)))
但是我得到这个错误:
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object
我该如何解决?
答案 0 :(得分:1)
totalText
的类型不是您所期望的。尝试用totalText.decode()
代替它。