You can use the $ notation for the last line to specify to the end of the file and double greater-than symbols (>>) after the w to indicate that you want to append to rather than overwrite the file.
对于最后一行,可以使用 $表示文件的末尾。 可以在w 后面使用两个大于号(>>)表示希望把内容附加到文件中而不是覆盖文件。
The next line creates a file object, passing in the name "testit.txt" and a 'w' character (to let you write to the file).
接下来的一行创建file对象,传递进名称“testit . txt ”和'w '字符(写入文件)。
'w' Open file, or create new file, for writing; discard existing contents, if any.
打开文件,创建新文件;将原有的内容去掉。
'w' Open file, or create new file, for writing; discard existing contents, if any.
打开文件,创建新文件;将原有的内容去掉。
应用推荐