[고1 프로그래밍] 09 - (3)

2023. 9. 18. 10:50·고1/프로그래밍
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()
저작자표시 (새창열림)

'고1 > 프로그래밍' 카테고리의 다른 글

[고1 프로그래밍] 09 - (5)  (0) 2023.09.25
[고1 프로그래밍] 09 - (4)  (0) 2023.09.20
[고1 프로그래밍] 09 - (2)  (0) 2023.09.13
[고1 프로그래밍] 09 - (1)  (0) 2023.09.11
[고1 프로그래밍] 08 - (1)  (0) 2023.08.30
'고1/프로그래밍' 카테고리의 다른 글
  • [고1 프로그래밍] 09 - (5)
  • [고1 프로그래밍] 09 - (4)
  • [고1 프로그래밍] 09 - (2)
  • [고1 프로그래밍] 09 - (1)
백학도령
백학도령
  • 백학도령
    백학도령
  • 전체
    오늘
    어제
  • 공지사항

    • 유용한 청년
    • 목록 (110)
      • 웹디자인개발기능사 (5)
      • 티스토리 (1)
      • 고3 (5)
        • 응용 프로그래밍 (2)
        • 데이터베이스 (1)
        • 성공적인 직업생활 (1)
        • 비즈니스 영어 (1)
      • 고2 (40)
        • 문학 (4)
        • 수학 (4)
        • 인공지능 수학 (1)
        • 통합사회 (4)
        • 영어 (6)
        • 한국사 (6)
        • 일본어 (4)
        • 응용 프로그래밍 (3)
        • 게임 프로그래밍 (4)
        • 자료 구조 (4)
      • 고1 (59)
        • 국어 (4)
        • 수학 (4)
        • 과학 (4)
        • 영어 (4)
        • 프로그래밍 (16)
        • 화면구현 (11)
        • 게임엔진 (15)
        • 인공지능 (1)
  • hELLO· Designed By정상우.v4.10.3
백학도령
[고1 프로그래밍] 09 - (3)
상단으로

티스토리툴바