zoukankan      html  css  js  c++  java
  • python 使用for 实现死循环

    code

    import time
    
    #——————————————————————————————————————————————
    #死循环打印1
    '''
    def count_n1():
        return 1
    
    for i in iter(count_n1, 6):
        print(i)
    
    '''
    
    #——————————————————————————————————————————————
    #打印
    # 1
    # 2
    # 3
    # 4
    # 5
    
    n=0
    
    def count_n2():
        global n
        n=n+1
        return n
    
    for i in iter(count_n2, 6):
        print(i)

  • 相关阅读:
    POJ 2154
    POJ 1286
    Polycarp's problems
    Greedy Change
    Goods transportation
    Ugly Problem
    Happy Matt Friends
    Dense Subsequence
    Ray Tracing
    Batch Sort
  • 原文地址:https://www.cnblogs.com/sea-stream/p/13551454.html
Copyright © 2011-2022 走看看