dict 형식 이용하여 변수명 자동 설정하기. [2018.09.13]
vars()['name {}'.format(variable)] = 1 #name variable 이라는 variable에 1이 들어간다.
globals()['name {}'.format(variable)] = 2 #name variable 이라는 global variable에 2가 들어간다.
ex)
a=1
vars()['name_{}'.format(a)]=1
print name_a
==> 1 출력.
'Mathematica&Python' 카테고리의 다른 글
matplotlib.pyplot 이용하여 그래프 꾸미기 [2018.09.12] (0) | 2018.09.13 |
---|---|
pandas 이용하여 python에서 excel file의 data 다루기. [2018.09.12] (0) | 2018.09.12 |
[2017.04.14] python 3.x버전에서 pip 사용법 (0) | 2017.04.14 |
[2017.04.14] linux mint 17.3에서 python3.5를 기본으로 바꾸기 (0) | 2017.04.14 |
[2017.04.10] Vpython 설치 (windows10) (0) | 2017.04.07 |