python 문자열 변수 그룹

497 단어 잔재주
import re

line = '''{name:'  ',name:'  ', geoCoord:[103.73, 36.03]},'''
city = re.findall("name:'(\w+)'",line)
code = re.findall("\[\d+.\d+,\s\d+.\d+\]", line)
# code = re.findall("Coord:\[(\d+.\d+),\s(\d+.\d+)\]",line)
print(city)
print(code)
print(type(code[0]))
print(eval(code[0]))
print(type(eval(code[0])))
print(tuple(eval(code[0])))
# print(tuple())
# print(tuple(map(float, code[0])))

좋은 웹페이지 즐겨찾기