Friday, 26 August 2022

python django how to merge two dict

 https://stackoverflow.com/questions/38987/how-do-i-merge-two-dictionaries-in-a-single-expression


For dictionaries x and y, their shallowly-merged dictionary z takes values from y, replacing those from x.

  • In Python 3.9.0 or greater (released 17 October 2020, PEP-584discussed here):

    z = x | y
    
  • In Python 3.5 or greater:

    z = {**x, **y}

No comments:

Post a Comment