问答详情
源自:2-3 Python实例属性的定义

类属于中文报错?

# Enter a code

class Animal(): pass


dog = Animal()

dog.name = "旺财"

dog.age = 2


cat = Animal()

cat.name = 'Tom'

cat.age = 3


提问者:回首已是千年 2022-04-29 18:03

个回答

  • 慕后端4177492
    2022-05-11 11:33:29

    #coding=utf-8   

    class Animal(): pass


    dog = Animal()

    dog.name = "旺财"

    dog.age = 2


    cat = Animal()

    cat.name = 'Tom'

    cat.age = 3