我正在写一个代码来记录一个员工系统,这个类可以打印全名,电子邮件:
class Employee:
def __init__(self,first,last):
self.first=first
self.last=last
def fullname(self):
print('{} {}'.format(self.first,self.last))
def email(self):
print('{}.{}@email.com'.format(self.first,self.last))
emp_1=Employee('John','Smith')
emp_1.first='Jim'
print(emp_1.first)
print(emp_1.email())
print(emp_1.fullname())
输出如下:
我不明白为什么我调用方法(
email()
,
fullname()
),我有一个
None
在输出范围内?
输出为:
Jim
Jim.Smith@email.com
None
Jim
Smith
None