Django(장고)/Django Q&A
리스트에 있는 모든 string 을 int 로 변경하기
브라이언77
2020. 4. 8. 08:15
반응형
리스트에 있는 모든 string 을 int 로 변경하기
Python 3.
map() 에서는 map 객체로 반환하기 때문에 마지막에 한번더 list 로 type 변경해줄 필요가 있다.
Python 2.
map 에 원하는 type 과 함께 넣고 변경하면 된다.
자료출처 :
https://stackoverflow.com/questions/7422453/python-change-type-of-whole-list
Python change type of whole list?
I would like to do something like this def foo(x,dtype=long): return magic_function_changing_listtype_to_dtype(x) i.e. a list full of str to a list full of int any easy way to do it for nested
stackoverflow.com
끝.