try...finally 异常,try...finally,异常处理import t
try...finally 异常,try...finally,异常处理import t
异常处理
import time #引进time因为这里包含了线程问题try: #我试图 f = file("D:/dooo.txt") #指定文件路径 while True: # while循环 后面是布尔表达式 你懂得 line = f.readline() # 一行行读取 if len(line) == 0: #如果长度小于行数 break #跳出 time.sleep(2) # 每隔2秒 循环一次 线程问题 print line, # 打印行 finally: # 最后 f.close() #关闭 print '\n Cleaning up...closed the file'
相关内容
- 文件读写,,文件读写#第九章 文件#
- 字典 暗示,字典,[Python]代码#
- 字典,,字典-基础# 字典#
- python Singleton pattern,pythonsingleton,Python singl
- while循环输出(1-10),while循环输出1-10,[Python]代码i
- python读取目录下文件并生成日志,,[Python]代码
- UTF8文件去BOM,UTF8文件BOM,[Python]代码#!
- python使用sha1加密方法验证文件的有效性,,import hashl
- 批量去除UTF8的Bom标签,utf8bom标签,#!/usr/bin/p
- 周长画圆,周长,[Python]代码im
评论关闭