Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver1
9いいね 348 views回再生

Dictionary Of An Object? Using __dict__ #shorts #python #pythonforbeginners

Did you know you can get at your object's data in dictionary form?

All you need to do is use the _dict_ attribute of our object.

Calling my_object.__dict__ will return a dictionary containing the attributes of that object.

But there's more!

We can also use vars() to accomplish the same thing. All we have to do is call vars and pass in our object. It will retain a dictionary of that object's attributes!

コメント