https://github.com/ansonallseitz/pythonDrills/blob/master/Liang/ch14/FileEditor.py
这个代码不是我写的,它来自教科书。
第47-58行有2个函数。我了解关于功能的一切,接受使用";结束";
我重读了这一章,却不知道他们在说什么。
def openFile(self):
filenameforReading = askopenfilename()
infile = open(filenameforReading, "r")
self.text.insert(END, infile.read()) # <- this "END"
infile.close() # Close the input file
def saveFile(self):
filenameforWriting = asksaveasfilename()
outfile = open(filenameforWriting, "w")
# Write to the file
outfile.write(self.text.get(1.0, END)) # <- and this "END"
outfile.close() # Close the output file
我读了这一章,然后在谷歌上搜索。我搞不清楚这里到底发生了什么事。
我的意思是。。。我知道这是关于读写文件的。
"1.0"
这里表示文本的开始,END
或"end"
表示文本的结束。.get
方法要求将起点和终点作为其参数。
我建议检查以下内容:https://dafarry.github.io/tkinterbook/text.htm