python 归纳 (一)_python组织方式

结论:

xxx.yyyy
yyyy 可以是 类、类对象、函数、变量
xxx  可以是 包、模块、类

代码:

ref1.py

# -*- coding: utf-8 -*-
import os

class abccc(object):
    def f(self,a):
        print a
c = abccc
d = abccc()
e = 5
def f(a):
    print "aa" + a

test1.py

# -*- coding: utf-8 -*-
"""
xxx.yyyy
yyyy 可以是 类、类对象、函数、变量
xxx  可以是 包、模块、类
"""
import  ref1

print type(ref1.abccc)
print ref1.e
ref1.f("6")

ref1.d.f("8")

e = ref1.c()
print type(e)
print type(ref1.e)
e.f("dd")

输出:

<type 'type'>
5
aa6
8
<class 'ref1.abccc'>
<type 'int'>
dd

后续 :

验证 xxx 是否可以 函数、方法

推测:

zzzzz.xxx.yyyy(_,_,..)
xxx 可以是 包、模块、类、类对象
? 函数

猜你喜欢

转载自www.cnblogs.com/sunzebo/p/9557688.html