古人学问无遗力,少壮工夫老始成。
纸上得来终觉浅,绝知此事要躬行。
——陆游
![](https://img.haomeiwen.com/i21032798/9ce92702a843d2ad.png)
1. 前言
在这个生活中处处都是大数据和人工智能的时代,总是能在各种角落看到 Python 的培训广告。我招架不住敌方的猛烈攻势,败下阵来。经过了一分钟的深思熟虑,我决定利用我的三分钟热情进行回击,从零开始自学 Python。
2.
Reading and Writing Files with Python
使用 Python 读写文件
2.1
Steps to reading or writing files in Python
使用 Python 读写文件的步骤
-
Call the
open()
function to return aFile
object.
调用open()
函数,返回一个File
对象。 -
Call the
read()
orwrite()
method on theFile
object.
调用File
对象的read()
或write()
方法。 -
Close the file by calling the
close()
method on theFile
object.
读写操作完成后,调用File
对象的close()
方法,关闭该文件。
网友评论