三分钟热情自学 Python · 第12期 · 使用 Pytho

2020-09-05  本文已影响0人  游文影月志

古人学问无遗力,少壮工夫老始成。
纸上得来终觉浅,绝知此事要躬行。
——陆游

1. 前言

在这个生活中处处都是大数据和人工智能的时代,总是能在各种角落看到 Python 的培训广告。我招架不住敌方的猛烈攻势,败下阵来。经过了一分钟的深思熟虑,我决定利用我的三分钟热情进行回击,从零开始自学 Python

2.

Reading and Writing Files with Python

使用 Python 读写文件

2.1

Steps to reading or writing files in Python

使用 Python 读写文件的步骤

  1. Call the open() function to return a File object.
    调用 open() 函数,返回一个 File 对象。

  2. Call the read() or write() method on the File object.
    调用 File 对象的 read()write() 方法。

  3. Close the file by calling the close() method on the File object.
    读写操作完成后,调用 File 对象的 close() 方法,关闭该文件。

上一篇 下一篇

猜你喜欢

热点阅读