Object-oriented Python-basic grammar learning-01

Source: Internet
Author: User

#!/usr/bin/evn python                 ## #指定运行python解释器 (Linux system) # -*- coding:utf8 -*-                ## #设置支持中文字符集class  personaddress (object):               ### #创建一个PersonAddress   name classes;     name =  "Breaklinux"                ### #设置class   Variable name #########     mymail =   "[email protected]"        ### #设置class   variable mymail name #########     def aboutperson (self):              #### #编写一个aboutPerson名的方法        print  "My Name:",  personaddress.name ## #调用class   Variable ###        print  "My original email address:",  personaddress.amail                                                                                                  def changeemail (Self,amail):           #### #编写一个修改邮箱地址的方法         personaddress.amail  = amail         print  "My mailbox has been replaced with: {0}". Format ( amail)  # #输出修改后的邮箱地址;        def deleteemail (self):                PersonAddress.amail =  ""                 print  "My mailbox has been deleted: {0}". Format ( Personaddress.amail)                           s = personaddress ()             # #实例化PersonAddress这个对象                                    s.aboutperson ()                # #调用  PersonAddress  class  aboutperson methods                                 s.changeemail ("[email protected]")     # #修改  PersonAddress  The property of the  changeemail method in the class S.deleteemail ()


Object-oriented Python-basic grammar learning-01

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.