字符串如何转换成字典
代码简化如下:import easygui as eg
choice_land=[{0: 'KK'}, {1: 'K'}, {2: 'K'}, {3: 'K'}, {4: 'KK'}, {5: 'K'}, {6: 'K'}, {7: 'K'}]
result = eg.choicebox(msg='原始板块要插入的位置:', choices=choice_land)
执行之后选择一个选项
result的值是字符串"{4: 'KK'}"
请问如何把"{4: 'KK'}"转换成{4: 'KK'}
eval()函数了解一下
>>> eval("{4: 'KK'}")
{4: 'KK'}
页:
[1]