我有一个列表,每个条目中有许多条目,用
[]
.例如。,
['1', 'pbkdf2_sha256$100000$sk3ONL23432fsdgUsHM62xa9XJHL+LkJHhK3cFGj8LYWGtOd8HC7Hs=',
'2018-09-25 19:32:41', '0', '', '', 'bob@trellis.law', 'Bob', 'Simon',
'bob@trellis.law', '1', '0', '2016-12-30 17:43:41', 'Bob Simon', 'Bob', '0', '1',
'', '[]', '', '0', '1', '0', '1', '', '', '1', '14', '191', '1', '0', '1', '0', '',
'', '', '0']
我想找到包含这个regex的条目,然后捕获
整个的
变量中的行:
r = re.compile(r'\w+\+\d+@trellis\.law')
我尝试过失败:
def import_csv(csv_file):
name_entries = []
with open(csv_file) as csvfile:
reader = csv.reader(csvfile)
name_entries.append(list(reader))
return name_entries
def exclude_regex_users(name_entries):
pulled_names = []
r = re.compile(r'\w+\+\d+@trellis\.law')
reader = csv.reader(name_entries)
for read in reader:
n = r.match(read)
if n:
pulled_names.append(n.group())
print(pulled_names)
我得到一个
_csv.Error: iterator should return strings, not list (did you open the file in text mode?)
是的。
啊。