📜  python 读取文件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:25.451000             🧑  作者: Mango

代码示例6
fileName = "file_name.txt" #Here you need to write the file name as a string

openLike = "" #Here you need to write how do you want to open the file:
#"w": Write, "r": Read
openedFile = open("file_name.txt", openLike) #Here you open the file
fileText = openedFile.read() #This read all the file
openedFile.close() #Close the file
print(fileText) # Prints the file text