zoukankan      html  css  js  c++  java
  • 创建一个名为User的类

    # -*- conding:utf-8 -*-
    class User:
        def __init__(self,first_name,last_name,age,sex,phone,login_attempts = 0):
            self.first_name = first_name
            self.last_name = last_name
            self.age = age
            self.sex = sex
            self.phone = phone
            self.login_attempts=login_attempts
        def describe_user(self):
            print('我叫 %s  %s,今年%d岁,我的电话是%s'%(self.first_name,self.last_name,self.age,self.phone))
        def greet_user(self):
            print('尊敬的%s,您好!'%self.first_name)
         #递增登录次数
        def increment_login_attempts(self):
            self.login_attempts += 1
            print('%s的登录次数为:%d'%(self.first_name,self.login_attempts))
         #重置登录次数
        def reset_login_attempts(self):
            self.login_attempts = 0
            print('%s的登录次数为:%d' % (self.first_name, self.login_attempts))
    if __name__ == '__main__':
        joe = User('Joe','Black',20,'','18011123333')
        #joe.describe_user()
        # joe.greet_user()
        joe.increment_login_attempts()
        joe.increment_login_attempts()
        joe.increment_login_attempts()
        joe.increment_login_attempts()
        joe.reset_login_attempts()
  • 相关阅读:
    InPut 标签 HTML(表单)
    JavaScript Table 对象
    JCBD
    JCBD
    JavaScript prototype 属性
    Java8 新特性
    JavaScript 对象的使用
    Java 反射
    虚拟机VirtualBox启动虚拟机报Only Ethernet Adapter' (VERR_INTNET_FLT_IF_NOT_FOUND).
    Impala 数值函数
  • 原文地址:https://www.cnblogs.com/xyg-zyx/p/8884364.html
Copyright © 2011-2022 走看看