有没有办法让这个逻辑:
如果条件不成立,我需要做一次陈述,如下所示:
while 1:
statement1
statement2
if condition: --condition is true here
statement3
else --condition is false here
statement3 --I need to do this "statement3" one time only
if another condition:
break
我的意思是,如果speed>;3或者只发送一次数据,我需要发送数据。在
有什么帮助吗
我解决了。我只需要在“Alex Martelli”的解中添加额外的“neverdone=True”
^{pr2}$非常感谢Alex Martelli。在
添加布尔变量:
你不能在
statement3
后面加一个break
语句吗?这意味着它将运行一次,然后while
循环将退出。在您可以使用标志,或写下以下内容:
当条件为false时,这将破坏state3。在
相关问题 更多 >
编程相关推荐