一般采用显示关闭文件:
f = open('./weibo.py','r')
print f.read()
f.close()
with open('./weibo.py') as f: for line in f: print line退出with代码块时文件自动关闭,不需显示关闭。