说明:工欲善其事必先利其器,Studies in Crop Variation. II. The manurial response of different potato va...该文档为Studies in Crop Variation. II. The manurial response of different potato varieties,是一份很不错的参考资料,具有较高参考价值,感兴趣的可以下载看看 <weixin_38610012> 上传 | 大小:987kb
说明:有一些任务,可能事先需要设置,事后做清理工作。对于这种场景,Python的with语句提供了一种非常方便的处理方式。一个很好的例子是文件处理,你需要获取一个文件句柄,从文件中读取数据,然后关闭文件句柄。 Without the with statement, one would write something along the lines of: 如果不用with语句,代码如下:
file = open("/tmp/foo.txt")
data = file.read()
file.clos <weixin_38556394> 上传 | 大小:56kb