예제 #1
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Author: yeshengwei
# E-mail: [email protected]

# from module1 import say_hello
from module2 import say_hello
from module1 import say_hello as M1_say_hello

# 从2个模块中导入同名的方法
say_hello()
M1_say_hello()

# 后导入的会覆盖先导入的
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Author: yeshengwei
# E-mail: [email protected]

# 一次性导入模块中的所有工具
import module1 as Md1
import module2 as Md2

# 使用模块别名调用方法
Md1.say_hello()
# 使用模块别名调用方法
Md2.say_hello()
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Author: yeshengwei
# E-mail: [email protected]

import module1
import module2

# 调用模块1的方法
module1.say_hello()

# 调用模块2的方法
module2.say_hello()

dog = module1.Dog()

cat = module2.Cat()
예제 #4
0
import module1 as DogModule
import module2 as CatModule

DogModule.say_hello()
CatModule.say_hello()

dog1 = DogModule.Dog()
cat1 = CatModule.Cat()

print(dog1)
print(cat1)