我目前是初学者是python,我想知道下面这个方法的简单方法是什么?
for i in range (20100,20130):
print ("s0", i, "@gmail.com", sep='')
for i in range (20200,20230):
print ("s0", i, "@gmail.com", sep='')
for i in range (20300,20330):
print ("s0", i, "@gmail.com", sep='')
for i in range (20400,20430):
print ("s0", i, "@gmail.com", sep='')
for i in range (20500,20530):
print ("s0", i, "@gmail.com", sep='')
for i in range (20600,20630):
print ("s0", i, "@gmail.com", sep='')
答案 0 :(得分:2)
使用Python的一个优点是,您几乎总能将任何循环/结构/ if语句放在另一个循环/结构/ if语句中。
代码:
for j in range(20100,20601,100):
for i in range (j,j+30):
print ("s0", i, "@gmail.com", sep='')
现在,我们遍历2个变量!