标签:默认 car div str 16px res size lis int
1: for 循环可以循环如下类型:
my_string = "abcabc" // 字符串类型 for c in my_string: print(c, end=‘ ‘) cars = [‘aa‘,‘bb‘,‘cc‘] // list类型 for car in cars: print(car) d = {‘one‘:1, "tow":2} // 字典类型, for key in d: // 默认是key print(key + " " + str(d[key]))
t = (1, 2, 3) // 元组
for item in t:
print(item)
2 循环多个
zip函数:打包
l1 = [1, 2, 3] l2 = [6, 7, 8, 20] for k in zip(l1, l2): print(k)
result:
(1, 6)
(2, 7)
(3, 8)
标签:默认 car div str 16px res size lis int
原文地址:https://www.cnblogs.com/liufei1983/p/9863057.html