for i in range(10):
globals()['x{}'.format(i)] = i
# 출력 결과
>> x1 = 1
x2 = 2
x3 = 3
…
활용 예시
# 차례대로 파일 불러서 변수 명 붙이기
import pandas as pd
from glob import glob
files = glob("*.csv",recursive=True)
for idx, filename in enumerate(files):
globals()['df{}'.format(idx)] = pd.read_csv(f"{filename}")
'Python' 카테고리의 다른 글
[Python][Pandas] 파일 불러오기 및 csv 저장하기 (0) | 2022.10.17 |
---|---|
[Python] venv으로 가상환경 만들기 (0) | 2022.09.27 |
[Python] 오프라인환경에서 라이브러리 설치 (0) | 2021.10.28 |
[Python] timedelta to int/ timedelta to seconds (0) | 2021.07.13 |
[Python][anaconda] 가상환경 만들기 conda create -n (0) | 2021.07.13 |