||
try:
...
break
except (RuntimeError,TypeError,NameError,ImportError):
print ".."(pass也可以)
else:
print "result is,%f"%result
防止文件myfile.txt忘了关闭,因此采用with 确保f总是关闭的
with open("myfile.txt")as f:
for line in f:
print line
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-22 16:27
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社