我有一个csv文件,我想在阿拉伯语中搜索一个特定的单词
lines = 0
with io.open('path.csv','r',encoding="utf-8") as f:
for line in f :
lines= lines+1
r=re.search(r'\w''[\u0627\u0644\u0631\u064A\u0627\u0636]',f)
print (line,r)
f.close()
我想打印带有单词的行就像将包含我的单词的行提取到新的csv文件
我收到此错误
traceback (most recent call last):
File "path.py", line 11, in <module>
r=re.search(r'\w''[\u0627\u0644\u0631\u064A\u0627\u0636]',f)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 182, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
答案 0 :(得分:0)
这里有一些评论:
这是怎么回事:
import io
import re
lines = 0
with io.open('path.csv','r', encoding="utf-8") as f:
for line in f :
lines += 1
r = re.search('\u0627\u0644\u0631\u064A\u0627\u0636', line)
if r:
print (lines, r)