繁体   English   中英

不理解 python 中的部分代码

[英]didnt understand a part of a code in python

您能告诉我以下 python 代码的第 6 行如何。

command = ""
started = False
while True:
    command = input("> ")
    if command == "start":
        if started:       #didnt understand this
            print("Car already started")
        else:
            started = True
            print("Car started ... ready to go")
    elif command == "stop":
        print("Car stopped")
    elif command == "help":
        print('''start - to start the
                 stop - to stop the car
                 quit - to exit''')
    elif command == "quit":
        break
    else:
        print("I don't get it")

第六行说如果 started 是True那么print("Car already started") 它比说if started == True更简单,但意味着与started相同的事情仅评估为TrueFalse

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM