本文整理汇总了Python中student.Student.age方法的典型用法代码示例。如果您正苦于以下问题:Python Student.age方法的具体用法?Python Student.age怎么用?Python Student.age使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student.Student
的用法示例。
在下文中一共展示了Student.age方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import age [as 别名]
def store(self, name, age, gpa, grade):
student = Student()
student.name = name
student.age = age
student.gpa = gpa
student.grade = grade
self.students.append(student)
示例2: Fib
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import age [as 别名]
#!/usr/bon/env python3
# -*- coding:utf-8 -*-
from fib import Fib
from student import Student
# __iter__
for n in Fib():
print('n = ',n)
# __getitem__
f = Fib()
print('f[1] = ', f[1])
# slice
print('f[:5] = ',f[1:10])
# attr
s = Student()
age = s.age()
print(age)
# sex = s.sex()
# print(sex)
#call
dy = Student('Dylan')
dy()
示例3: Student
# 需要导入模块: from student import Student [as 别名]
# 或者: from student.Student import age [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#从student模块中导入Student类
from student import Student
s = Student('s1')
print s.name
#给Student动态绑定年龄属性
s.age = 18
print s.age
#给Student动态绑定方法
def setAge(self,age):
self.age = age
from types import MethodType
s.setAge = MethodType(setAge,s,Student)
s.setAge(19)
print s.age
#给一个实例动态绑定年龄和方法对别的实例没有影响
s2 = Student('s2')
# print s2.age
#为了给所有实例绑定方法 ,可以给class绑定方法
Student.setAge = MethodType(setAge,None,Student)
s2.setAge(20)
print s2.age
#为了给所有实例绑定属性,可以给class 绑定属性
Student.hello = 'sssss'