我在控制台中没有收到任何错误或结果。它应该将mchaps作为用户名打印
class User:
def SetUserName(self, userName):
self._UserName = userName
def GetUserName(self):
return self._UserName
def main():
u1 = User()
u1.SetUserName('mchaps')
print(u1.GetUserName())
u2 = User()
u2.SetUserName('chapsking')
print(u2.GetUserName())
if __name__ == '__main__':main()
Process finished with exit code 0
原则上,您可以
您需要调用main方法。