小编bay*_*bay的帖子

在Python中递归转换字典

这是字典:

data = {
    'a': {
        'b': {
            'c': {
                'd': {
                    'e': {
                        'f': 1,
                        'g': 50,
                        'h': [1, 2, 4],
                        'i': 3,
                        'j': [7, 9, 6],
                        'k': [
                            [('x', 'abc')],
                            [('y', 'qwe')],
                            [('z', 'zxc')]
                        ]
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我的目标是在可能的情况下查找值并将其转换为字典:

data = {
    'a': {
        'b': {
            'c': {
                'd': {
                    'e': {
                        'f': 1,
                        'g': 50,
                        'h': [1, 2, 4],
                        'i': 3,
                        'j': [7, 9, 6],
                        'k': [{
                            'x': 'abc'
                        }, {
                            'y': 'qwe'
                        }, …
Run Code Online (Sandbox Code Playgroud)

python recursion dictionary

5
推荐指数
1
解决办法
990
查看次数

标签 统计

dictionary ×1

python ×1

recursion ×1