Python (Knowledge point: Class) simply creates a class

Source: Internet
Author: User

#!/usr/bin/env python#-*-coding:utf-8-*-"" "Created on Mon-Nov 01:01:29 2016@author:toby" "" #知识点: Classes and Objects # noun: 1, instantiate a class, generate    An object that is instantiated by the class to generate an object class Animal:body = ' four legs ' class Human: #类的名称 BODY = ' hands, feet, nose, eyes, ears, face ' def __init__ (self,name,age): #为了实例化的一个特殊函数, action for instantiation self.name = name #定义属性 Self.age = Age #定义属性h1 = Human (' job ') #实例化一个类的对象print h1.name #打印出这个对象的属性print h1.ageh2 = Human (' Jack ') print H2.nameprint h2.age


This article is from the "Fa&it-Q Group: 223843163" blog, please be sure to keep this source http://freshair.blog.51cto.com/8272891/1873516

Python (Knowledge point: Class) simply creates a class

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.