我有这个输出
(10.76, 27.73)
我希望将它作为值分配给一个键,这里是一个代码
dictionary = {'whatever':'whatever, 'KEY':'I need this output(tuple) here'}
另外,细节很少,我宁愿保留逗号,但如果不可能,我会自己添加,这没关系。
谢谢
答案 0 :(得分:2)
只需指定它。
>>> t = (10.76, 27.73)
>>> d = {}
>>> d['key'] = t
>>> d
{'key': (10.76, 27.73)}
答案 1 :(得分:0)
mytuple = (10.76, 27.73)
dictionary = {'whatever':'whatever', 'KEY':mytuple}
{' KEY':(10.76,27.73),'无论':'无论'}
或
mytuple = (10.76, 27.73)
dictionary = {'whatever':'whatever', 'KEY':str(mytuple)}
{' KEY':'(10.76,27.73)','无论':'无论'}