티스토리 뷰
write-only mode ("w")
read-only mode ("r")
read and write mode ("r+")
append mode ("a"), which adds any new data you write to the file to the end of the file.
my_file = open("output.txt", "r")
print my_file.read()
my_file.close()
my_file = open("text.txt", "r")
print my_file.readline()
print my_file.readline()
print my_file.readline()
my_file.close()
with open("text.txt", "w") as textfile:
textfile.write("Success!")
'IT > Python: Codecademy' 카테고리의 다른 글
11 Introduction to Classes (0) | 2018.03.10 |
---|---|
Sec10: bit calculator (0) | 2018.03.08 |
10 Advanced Topics in Python (0) | 2018.03.07 |
9 Exam Statistics (0) | 2018.03.06 |
8 Loop (0) | 2018.02.28 |
댓글