美文网首页python百例
23-for循环遍历数据对象

23-for循环遍历数据对象

作者: 凯茜的老爸 | 来源:发表于2018-07-30 08:40 被阅读83次
astr = 'hello'
alist = [10, 20, 30]
atuple = ('bob', 'tom', 'alice')
adict = {'name': 'john', 'age': 23}

for ch in astr:
    print(ch)

for i in alist:
    print(i)

for name in atuple:
    print(name)

for key in adict:
    print('%s: %s' % (key, adict[key]))

相关文章

网友评论

    本文标题:23-for循环遍历数据对象

    本文链接:https://www.haomeiwen.com/subject/cajxvftx.html