끄적끄적 코딩
Published 2020. 9. 15. 01:50
[파이썬] with Python

pickle 파일을 with를 통해 읽어들이는 방법

import pickle

with open("test.pickle", "rb") as test_file:
    print(pickle.load(test_file))

 

with를 이용해 쓰고 읽는 방법

with open("python.txt", "w", encoding="utf8") as python_file:
    python_file.write("Hello, Python!")

with open("python.txt", "r", encoding="utf8") as python_file:
    print(python_file.read())

'Python' 카테고리의 다른 글

[파이썬] 상속, 다중 상속  (0) 2020.09.15
[파이썬] 클래스  (0) 2020.09.15
[파이썬] pickle  (0) 2020.09.13
[파이썬] 파일 입출력  (0) 2020.09.11
[파이썬] print 속성, 포맷  (0) 2020.09.11

검색 태그