Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 301 Bytes

File metadata and controls

18 lines (13 loc) · 301 Bytes

普通方式读取文件内容

f = open("readme.md", "r", "utf-8")
content = f.read()
f.close()
print(content)

pythonic 方式读取文件,上下文with语句会自动关闭文件对象

with open("readme", "r", "utf-8") as f:
    content = f.read()
print(content)