-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.py
More file actions
40 lines (33 loc) · 1.21 KB
/
file.py
File metadata and controls
40 lines (33 loc) · 1.21 KB
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
32
33
34
35
36
37
38
39
40
score_file = open("score.txt", "w", encoding="utf8")
print("수학 : 0", file= score_file)
print("영어 : 50", file=score_file)
score_file.close()
score_file = open("score.txt", "a", encoding="utf8")
score_file.write("과학 : 80")
score_file.write("\n코딩 : 80")
score_file.close()
# score_file = open("score.txt", "r", encoding="utf8")
# print(score_file.readline(), end="")
# print(score_file.readline(), end="")
# print(score_file.readline(), end="")
# print(score_file.readline(), end="")
# score_file.close()
score_file = open("score.txt", "r", encoding="utf8")
while True:
line = score_file.readline()
if not line:
break
print(line)
score_file.close()
import pickle
profile_file = open("profile.pickle", "wb",)
profile = {"이름":"박명수", "나이":30, "취미":["축구", "골프", "코딩"]}
print(profile)
pickle.dump(profile, profile_file)
profile_file.close()
with open("profile.pickle", "rb") as profile_file:
print(pickle.load(profile_file))
with open("study.txt", "w", encoding="utf8") as study_file:
study_file.write("파이썬을 공부하고 있어요")
with open("study.txt", "r", encoding="utf8") as study_file:
print(study_file.read())