# 读取文件
with
open
(
'file.txt'
,
'r'
) as f:
content
=
f.read()
# 写入文件
'w'
f.write(
'Hello, world!'
)
# 检查文件是否存在
import
os
if
os.path.exists(
):
print
'File exists'