兩個for參數的for循環寫法


兩個for參數的for循環寫法

if __name__ == '__main__':
    # zip函數
    a = [1, 2, 3]
    b = [4, 5, 6]
    c = [4, 5, 6, 7, 8]
    p = zip(a, b)
    for x in p:
        print(x)
    '''結果
        (1, 4)
        (2, 5)
        (3, 6)
    '''
    w=zip(a,c)
    for x in w:
        print(w)
    #     兩個參數,誰先結束了,循環也就結束了
    for x,c in zip(range(0,6),range(0,5)):
        print(x,c)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM