阅读背景:

如何避免AttributeError并在Python中获取未定义的值?

来源:互联网 

I'm somewhat new to Python and I want to create a function that takes a parameter that is an dictionary that contains multiple entries. The function has an object with some given properties (e.g.: color, title, description...). If the dictionary from the paramter contains an entry named 'color' it should give the object's property the value of 'color', otherwise the property 'color' in the object should be undefined/empty. I know that in JavaScript this is simply done as following:I'm somewhat new to Python and I want to create




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: