티스토리 뷰

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
댓글
Announcement
Recent Posts
Recent Comments
Total
Today
Yesterday
Link
TAG
more
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Search by month