📜  尝试for循环python代码示例

📅  最后修改于: 2022-03-11 14:47:06.926000             🧑  作者: Mango

代码示例1
try:   
    with open('sample.txt','r') as file:
        for line in file:
            (some action here)
except IOError:
    except IOError as (errno, strerror):
        print "I/O error({0}): {1}".format(errno, strerror)