I have this output
(10.76, 27.73)
and I want to assign it to a key as a value, here is a code
dictionary = {'whatever':'whatever, 'KEY':'I need this output(tuple) here'}
Also, little detail, I would prefer to keep the comma, but if not possible i'll just add it on my own, that's ok.
Thank you
Simply assign it.
>>> t = (10.76, 27.73)
>>> d = {}
>>> d['key'] = t
>>> d
{'key': (10.76, 27.73)}
mytuple = (10.76, 27.73) dictionary = {'whatever':'whatever', 'KEY':mytuple}
{'KEY': (10.76, 27.73), 'whatever': 'whatever'}
or
mytuple = (10.76, 27.73) dictionary = {'whatever':'whatever', 'KEY':str(mytuple)}
{'KEY': '(10.76, 27.73)', 'whatever': 'whatever'}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.