代码块一:
f = open('/tmp/passwd')
with open('/tmp/passwd') as f:
print(f.read())
示例一及运行结果:
代码块二:
with open('/tmp/passwd') as f1,\
open('/tmp/passwd1','w+') as f2:
f2.write(f1.read())
f2.seek(0,0)
print(f2.read())
示例二及运行结果: