import pickle
profile3_file = open("profile3.pickle", "wb")
profile3 = {"이름":"박명수", "나이":30, "취미":["축구", "골프", "코딩"]}
print(profile3)
pickle.dump(profile3, profile3_file)
profile3_file.close()
# import pickle
# profile3_file = open("profile3.pickle", "rb")
# profile3 = pickle.load(profile3_file)
# print(profile3)
# profile3_file.close()
import pickle
with open("profile3.pickle", "rb") as profile3_file:
print(pickle.load(profile3_file))
with open("study3.txt", "w", encoding="utf-8") as study3_file:
print(study3_file.write("파이썬을 열심히 공부하고 있어요."))
with open("study3.txt", "r", encoding="utf-8") as study3_file:
print(study3_file.read())
class Monster:
def __init__(self, name):
self.name = name
def say(self):
print(f"나는 {self.name}")
shark = Monster("상어")
shark.say()
wolf = Monster("늑대")
wolf.say()