出现于正则表达式,主要意思是数据类型不匹配。
file = open("./he.txt", 'r')
corpus = file.read()
word = str(corpus)
pattern = re.findall(r'(因为.{,})', word) # 这里re.findall(corpus)会报错,因为数据不是str型
print(pattern)
修改:转换数据结构,加入str()
可以输出type看看本来的结构是什么,最后只要修改成str就好啦
出现于正则表达式,主要意思是数据类型不匹配。
file = open("./he.txt", 'r')
corpus = file.read()
word = str(corpus)
pattern = re.findall(r'(因为.{,})', word) # 这里re.findall(corpus)会报错,因为数据不是str型
print(pattern)
修改:转换数据结构,加入str()
可以输出type看看本来的结构是什么,最后只要修改成str就好啦