How to create inline objects with properties?

后端 未结 9 710
误落风尘
误落风尘 2020-12-04 19:12

In Javascript it would be:

var newObject = { \'propertyName\' : \'propertyValue\' };
newObject.propertyName;  // retur         


        
9条回答
  •  粉色の甜心
    2020-12-04 19:38

    class test:
        def __setattr__(self,key,value):
            return value
    
    
    myObj = test()
    myObj.mykey = 'abc' # set your property and value
    

提交回复
热议问题