Python file IO operations
2016-08-23
0 0 0
no vote
Other
Earn points
filePath="c:/test/tt.txt"
# Reads information from the files
F=open (filePath, "r") # using file opened for reading,
For line in f: # every time you read a file line
print(line)
f.close()
# Write information to the file
F=open (filePath, "a") # here in two ways: the first is in the form of w, it will clear previous data when writing and then write data, the second is based on a form of, write it in the form of additional data
F.write ("I began to write information to the file n")
F.writelines ("I have written to the file information")
f.close()
# Reads information from the files
F=open (filePath, "r") # using file opened for reading,
For line in f: # every time you read a file line
print(line)
f.close()
# Write information to the file
F=open (filePath, "a") # here in two ways: the first is in the form of w, it will clear previous data when writing and then write data, the second is based on a form of, write it in the form of additional data
F.write ("I began to write information to the file n")
F.writelines ("I have written to the file information")
f.close()
python
io
操作
文件
Related Source Codes
Word memorization software
0
0
no vote
CWT Python example
0
0
no vote
STFT example
0
0
no vote
Chinese Speech Recognition
0
0
no vote
python-ela
0
0
no vote
No comment