- 0. 파일 읽고 쓰기는 무조건 string형태로 저장되고 읽어와짐.
따라서 읽어와서 형변환 하는 작업이 필요함.
- 1. 변환하기
1) dict list형태로 변환.
2) int list형태로 변환
import ost
f = open('tmp', 'r')
lines = f.readlines()
f.close()
#list-dict
dictlist = []
for i in range(len(lines):
dictlist.append(ast.literal_eval(lines[i]))
#list-int
intlist = []
for i in range(len(lines):
dictlist.append(int(lines[i]))
- 2. 참고사이트
'Computer > Python' 카테고리의 다른 글
[Python] Windows에 jupyter notebook 설치하기 [feat. 머신러닝] (0) | 2020.11.19 |
---|---|
[Python] shell에서 쓰는 명령어 실행하기 (0) | 2019.10.10 |
[Python] python으로 .py 돌리기 (0) | 2019.09.10 |
[Python] 디렉토리의 파일 접두사 삭제 (0) | 2019.09.09 |