Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
dict, int, decode solution in Clear category for YAML. More Types by flpo
const = {'': None, 'null': None, 'true': True, 'false': False}
def convert(value):
if value in const: return const[value]
if value.isdigit(): return int(value)
if value[0] in '"\'': return value[1:-1].encode('utf-8').decode('unicode_escape')
return value
def yaml(a):
res = {}
for s in filter(None, a.splitlines()):
key, value = s.split(':')
res[key] = convert(value.strip())
return res
Nov. 16, 2019
Comments: