How can I pass my locals and access the variables directly from another function?

前端 未结 5 825
没有蜡笔的小新
没有蜡笔的小新 2020-12-10 07:17

Let\'s say I have this :


def a(dict):
  locals().update(dict)
  print size

def b():
  size = 20
  f(locals())

What do I have to do to acc

5条回答
  •  我在风中等你
    2020-12-10 08:04

    Is this helping you somehow?

    def print_size(size=None):
        print(size)
    
    dict = {'size': 'XXL'}
    print_size(**dict)
    

提交回复
热议问题