![](/img/trans.png)
[英]Python 3.3 Beginner: Need help understand how the “and not” part of this code functions
[英]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
相同的事情仅评估为True
或False
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.