import p01 stu = p01.Student('shenwei', 24) stu.say() p01.sayHello()
import p01 as pp stu = pp.Student("junjun", 30) stu.say() pp.sayHello()
from p01 import Student,sayHello stu = Student() stu.say() sayHello()
import p01 as p stu = p.Student() stu.say() p.sayHello()
#-*- coding:UTF-8 -*- import p01 # 引入模块p01的标准模式 stu = p01.Student('wujian', 29) stu.say() p01.sayHello('wujian')
# _*_ coding:UTF-8 _*_ # 选择性导入,模块内容 from p01 import Student, sayHello stu = Student('wujian') stu.say() sayHello('BOX')
import p01 stu = p01.Student("xiaojign", 19) stu.say() p01.sayHello()
import p01 as a print(a.sayHello()) std = a.Student("a",1) print(std.say())
import p01 as module1 stu = module1.Student("yty", 19) stu.say() module1.sayHello()
from p01 import Student, sayHello stu = Student() stu.say() sayHello()
# -*- coding: utf-8 -*- # Author: IMS2017-MJR # Creation Date: 2019/5/5 import p01 # 导入这个模块,就相当于将模块中的代码粘贴到了这里并执行一遍,所以其中print等代码会直接执行,最好不要有。 stu = p01.Student("cjx", 22) stu.say() p01.sayHello() print("#" * 50) import p01 as p stu = p.Student("anran", 22) stu.say() p.sayHello() print("#" * 50) from p01 import Student, sayHello stu = Student("cwy", 0) # 此时p01.的前缀都不需要,否则会报错 stu.say() sayHello()
import p01 as tuling stu = tuling.Student("xiaojing", 20) stu.say() tuling.sayHello()