简体   繁体   English

TypeError:“ NoneType”类型的参数不可迭代python

[英]TypeError: argument of type 'NoneType' is not iterable python

I keep getting this error for like 20 "if ntext[x] in dictionary:". 我不断收到此错误,例如20“ if ntext [x] in dictionary:”。 The program converts text talk into english. 该程序将文本对话转换为英语。

import csv
def CreateDictionary ():
    fo = open("textToEnglish2014.csv" , "r")
    dictonary = {}
    reader = csv.reader(fo)
    for row in reader:
        dictionary[row[0]] = row[1]
        return dictionary

def main():
    dictionary = CreateDictionary()
    y = "y"
    while y == "y":
        text = input("Enter text to which you would like conversion: ")
        text = text.lower()
        ntext = text.split(" ")
        new_text = ""
        x = 0
        while x < len(ntext):
            if ntext[x] in dictionary:
                new_text = new_text + dictionary[ntext[x]] + " "
            else:
                export = export + "NF "
            x += 1
        print (new_text)
        y = input("Continue conversion? y or q ")

main()
dictonary = {}

should be 应该

dictionary = {}

note the spelling 注意拼写

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python聊天机器人“ TypeError:&#39;NoneType&#39;类型的参数不可迭代” - Python chatbot “TypeError: argument of type 'NoneType' is not iterable” Python - TypeError:“NoneType”类型的参数不可迭代 - Python - TypeError: argument of type 'NoneType' is not iterable Python游戏| TypeError:“ NoneType”类型的参数不可迭代 - Python Game | TypeError: argument of type 'NoneType' is not iterable Python TypeError:“ NoneType”类型的参数不可迭代 - Python TypeError: argument of type 'NoneType' is not iterable python错误TypeError:&#39;NoneType&#39;类型的参数不可迭代 - The python error TypeError: argument of type 'NoneType' is not iterable TypeError:“NoneType”类型的参数在 python 中不可迭代 - TypeError: argument of type 'NoneType' is not iterable in python TypeError:NoneType 类型的参数在 python 中不可迭代 - TypeError: argument of type NoneType is not iterable in python TypeError:“NoneType”类型的参数不可迭代 - TypeError: argument of type 'NoneType' is not iterable “TypeError:'NoneType' 类型的参数不可迭代”? - “TypeError: argument of type 'NoneType' is not iterable”? 使用Python进行网络抓取:TypeError:“ NoneType”类型的参数不可迭代 - Using Python for web scraping: TypeError: argument of type 'NoneType' is not iterable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM