for

作者: fanbotao | 来源:发表于2018-07-19 16:36 被阅读0次

    # 循环读取一个范围里面的数据

    for iin range(10):

    print(i)

    for iin range(1,10):

    print(i)

    for iin range(1,10,2):

    print(i)

    # 循环读取字符串,tuple,list,set

    list1 = [1,2,3]

    tuple1 = (1,2,3)

    string1 ='123'

    set1 = {1,2,3}

    for iin string1:

    print(i)

    dict1 = {'id':1,'name':'zhangsan','age':11}

    # 读出所有的键值对

    for k,vin dict1.items():

    print(k,v)

    相关文章

      网友评论

          本文标题:for

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