Lấy dưới đây Ví dụ:Trong từ điển, chuyển đổi giá trị từ chuỗi để nguyên
'user_stats': {'Blog': '1',
'Discussions': '2',
'Followers': '21',
'Following': '21',
'Reading': '5'},
Tôi muốn chuyển đổi nó thành:
'Blog' : 1 , 'Discussion': 2, 'Followers': 21, 'Following': 21, 'Reading': 5
Lưu ý rằng ['iteritems'] (https://docs.python.org/2/library/stdtypes.html#dict.iteritems) [đã biến mất] (http://stackoverflow.com/questions/10458437/ what-is-the-different-giữa-dict-items-và-dict-iteritems) trong [Python 3] (https://www.python.org/download/releases/3.0/). Sử dụng ['items()'] (https://docs.python.org/3.7/library/stdtypes.html#dict.items) để thay thế. –