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循环遍历数据对象

 


 
                    
            
                

相关文章:

  • 2021-12-28
  • 2022-12-23
  • 2021-12-18
  • 2021-12-18
  • 2021-12-28
  • 2022-12-23
  • 2021-12-28
  • 2021-06-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-12-28
  • 2022-12-23
  • 2021-06-21
相关资源
相似解决方案