Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何阻止Python忽略某些函数?_Python 3.x_Loops - Fatal编程技术网

Python 3.x 如何阻止Python忽略某些函数?

Python 3.x 如何阻止Python忽略某些函数?,python-3.x,loops,Python 3.x,Loops,我正在编程一个人工智能助手,它应该做很多操作。我已经对它进行了编程,数字触发程序的一部分的功能。然而,当我为我的绘图工具和翻译器添加功能时,我遇到了一个问题。对于绘图工具,Python完全忽略它。对于translator命令,在问了前两个问题之后,它没有完成代码,而是循环返回。我如何解决这个问题?所有其他功能正常工作 def turtledraw(): wn = turtle.Screen() wn.bgcolor("light blue") wn.title("Draw

我正在编程一个人工智能助手,它应该做很多操作。我已经对它进行了编程,数字触发程序的一部分的功能。然而,当我为我的绘图工具和翻译器添加功能时,我遇到了一个问题。对于绘图工具,Python完全忽略它。对于translator命令,在问了前两个问题之后,它没有完成代码,而是循环返回。我如何解决这个问题?所有其他功能正常工作

def turtledraw():
    wn = turtle.Screen()
    wn.bgcolor("light blue")
    wn.title("Draw Time!")
    tt = turtle.Turtle()
    tt.forward(100)


def translatetime():
    langask1 = input("What do you want to translate?")
    langask2 = input("Type the first two letters of the language you want to translate to")
    translator= Translator(to_lang="{}".format(langask2))
    translation = translator.translate("{}".format(langask1))














while True:
    taker = taken()
    if "1" in taker:
         searcher = input("What would you like to Search?")
         webbrowser.open("https://www.google.com/search?q=({})".format(searcher))
         print("Type Exit to do something else")
    if "Exit" in taker:
        taken()
        break
    if "Talk" in taker:
        talk_talk()

    if "3" in taker:
        wikifact_finder()
    if "4" in taker:
        answer_question()
    if "5" in taker:
        math_calculator()

    if "draw" in taker:
        turtledraw()
    if "9" in taker:
        translatetime()

wn
变量来自哪个模块?这就是我所称的海龟绘图模块的屏幕。哦,我明白了。我以前没用过土鳖模式!酷!我会读更多的文档。在查看您的问题后,对于翻译,我认为您需要在计算后打印翻译。对于绘图部分,我认为您需要调用
tt.mainloop()
tt.done()
,以使屏幕显示给用户。添加tt.mainloop()后,它抛出一个错误,表示“海龟”对象没有mainloop属性。对于翻译,它只打印langask1的输入,而不进行翻译。