我有一个带有键/值对的 .csv 文件。我试图通过调用我的字典来检查给定的键是否在文件中,但我有一个我不太明白的错误。任何帮助表示赞赏!
def Dictionary(x):
wDictionary = open('file.csv', 'r')
for line in wDictionary:
mylist = line.split(',')
def main():
x = input('enter text:')
cd = Dictionary(x)
if x in cd:
print('yes')
main()
错误:
Traceback (most recent call last):
File "7.py", line 15, in <module>
main()
File "7.py", line 12, in main
if x in cd:
TypeError: argument of type 'NoneType' is not iterable