while True:
x = False
if x == False:
if (float) <= (price):
if not safe_mode:
(Some function)
x = True
print(something)
elif x == True:
if (float) >= (price):
if not safe_mode:
(Some Function)
x = False
print(something)
Run Code Online (Sandbox Code Playgroud)
这是我的代码,我想要循环,但我得到的是'x'不想将值更改为'True'...并且'x = True'变灰.我不知道为什么它不想工作,我需要你所有的帮助.我有点压力找到问题:(
问题是你x回到循环False的每次迭代的开始while,所以它的值在每个条件块内改变,但是False在循环重新开始之后然后改回到右边.
只需x = False在while循环外部设置即可解决问题.例:
x = False
while True:
# do stuff
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
94 次 |
| 最近记录: |