组合数据类型练习

1.组合数据类型练习:

分别定义字符串,列表,元组,字典,集合,并进行遍历。

str = 'china'
for i in str:
    print(i)
a= ['a','b','c','d','e','f']
for i in a:
    print(i)
tu= ('physics', 'chemistry', 1997, 2000);
for i in range(len(tu)):
    print(tu[i])
d = {'a':1,'b':2,'c':3,'h':4}
for k,v in d.items():
    print(k,v)
st = set([1,2,'a','c',4,'d'])
for i in st :
    print(i)
原文地址:https://www.cnblogs.com/ming-z/p/8626160.html