获取原始密钥值

时间:2018-03-13 09:58:18

标签: python python-3.x

如何获取键值的原始字符串?

dictionary = {'key': ['value']}
print(dictionary.get('key'))

>>> ['value']

如何获取'value'而不是['value']

2 个答案:

答案 0 :(得分:0)

dictionary = {'key': ['value']}
print(dictionary.get('key')[0])

答案 1 :(得分:0)

试试这个:

dictionary = {'key': ['value']}
print(dictionary.get('key'))[0]

输出:

value
[Finished in 0.0s]