Cle*_*ent 2 python call return-value while-loop
我已经尝试了一段时间才能访问我最近返回的值并在if语句中使用它而不必调用该值.
基本上我有一个while循环调用一个允许用户输入然后将输入返回循环的函数.
while selection() != 0: ## Calls the "WHAT WOULD YOU LIKE TO DO" list and if it is 0 quits the script
input() ## just so it doesn't go straight away
if selection.return == 1: ## This is what I would like to happen but not sure how to do it... I've googled around a bit and checked python docs
Run Code Online (Sandbox Code Playgroud)
看看我是否:
if selection() == 1:
Run Code Online (Sandbox Code Playgroud)
它会工作,但再次显示"你想做什么"的文字......
如果这是一个明显的解决方案,我很抱歉,但非常感谢帮助:)
这就是您将结果存储在变量中的原因,以便将来可以引用它.就像是:
sel = selection()
while sel != 0:
input()
if sel==1:
...
sel = selection()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
154 次 |
| 最近记录: |