优纳美食网
您的当前位置:首页python怎么读取文本文件

python怎么读取文本文件

来源:优纳美食网


python怎么读取文本文件?

文件的读取

步骤:打开 -- 读取 -- 关闭

>>> f = open('/tmp/test.txt')
>>> f.read()
'hello python!
hello world!
'
>>> f.close()
显示全文