1.range
a = range(0 ,100 , 5) #创建>=0,<100的连续数字,步长为5 for b in a: print(b)
运算结果:
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 Process finished with exit code 0
2.
text = input("请输入:") print("您输入的数是:",text) a = len(text) print("有",a,"位") r = range(0,a) for b in r: print(b,text[b])
# 也可以简写
###
text = input("请输入:")
for b in range(0,len(text)):
print(b,text[b])
###
运算结果:
请输入:jaslkfaj 您输入的数是: jaslkfaj 有 8 位 0 j 1 a 2 s 3 l 4 k 5 f 6 a 7 j Process finished with exit code 0