只是一个路过的询问...
说我有一些课:
class Student:
def __init__(self, name, grade, school=None):
self.name = name
self.grade = grade
self.school = school
def enroll(self, school):
self.school = school
我知道我可以像这样调用对象的属性:
x = Student("John Doe", 12)
print( x.grade )
print( x.name )
但是有没有一种方法可以通过仅引用对象一次来从对象中顺序调用多个属性?
也许是这样的:
x.(grade,name)
会返回:
12 John Doe
明月笑刀无情
繁花不似锦
相关分类