【发布时间】:2017-11-13 20:28:25
【问题描述】:
我是 Python 的初学者,当我尝试在 CMD 上执行这个命令时,我遇到了这个错误。请指教:
代码:
import re
handle=open('regex_sum_41718.txt')
for line in handle:
word=line.split()
print(type(word))
y=re.findall('[0-9]+',word)
print(y)
错误:
Traceback (most recent call last):
File "Assi_1.py", line 5, in <module>
y=re.findall('[0-9]+', word)
File "D:\Python\lib\re.py", line 222, in findall
return _compile(pattern, flags).findall(string)
TypeError: expected string or bytes-like object
非常感谢。
【问题讨论】: