#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 14 01:01:29 2016
@author: toby
"""
#知识点:类和对象
#名词:1、实例化一个类,生成一个对象,通过类进行实例化来生成一个对象
class Animal:
body = ‘Four legs‘
class Human: #类的名称
body = ‘Hands, feet, nose, eyes, ears, face‘
def __init__(self,name,age): #为了实例化的一个特殊函数,用于实例化的动作
self.name = name #定义属性
self.age = age #定义属性
h1 = Human(‘job‘,18) #实例化一个类的对象
print h1.name #打印出这个对象的属性
print h1.age
h2 = Human(‘jack‘,20)
print h2.name
print h2.age
原文地址:http://freshair.blog.51cto.com/8272891/1873516