擅长:python、mysql、java
<p>您可以这样做(作为前面答案的替代方法):</p>
<pre><code>def loop(condition):
iterable = range(0,10) if condition else ['a','b','c']
return iterable
#Then you cxan go as:
for i in loop(True):
print('range')
#Or
for i in loop(False):
print("Dict or any iterable")
</code></pre>