📜  python打印文件内容——Python代码示例

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

代码示例1
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