Today we're going to talk about files, and the built-in functions associated with files open and file
First we build a txt text file named "123" in the root directory of Python
We'll enter some text inside the file.
We put both the new file and the source code under the Python root directory.
Let's take a look at the code:
Handler=open ("123.txt") #由于把文件跟源代码建立在python的根目录, #所以这里的路径只需打名字即可for eachline in handler: print (Eachline, End= ") Handler.close ()
Output Result:
File () is similar to open (), and the name is more consistent with the reading habit
Then we need to note that the above file is relatively small, if you put a 100m or more files into memory, the problem will occur, at that time we need additional processing methods, we need to read while writing, to reduce the use of memory, this we are expanding behind.
This is the section here, thank you.
------------------------------------------------------------------
Click to jump 0 basic python-Catalogue
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
0 basic python-2.17 files, open (), file ()