class User: totalUser = 0

def __init__(self, id, password):
    self.id = id
    self.password = password
    self.username = "user" + str(id)
    self.emailAdrr = self.username + "@gameschool.com"
    User.totalUser += 1

user1 = User(1, "123456") user2 = User(2, "abcdef") user3 = User(3, "qwerty")

print("用户总人数:", User.totalUser)

Python 网络用户类定义与实例化 - 包含用户ID、用户名、密码和邮箱

原文地址: https://www.cveoy.top/t/topic/pRDH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录