C:\Users\Administrator>python Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', 'E:\\Project\\Python\\ModuleAndPackage', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python\\DLLs', 'C:\\Python\\lib', 'C:\\Python\\lib\\plat-win', 'C:\\Python\\lib\\lib-tk', 'C:\\Python', 'C:\\Python\\lib\\site-packages'] >>>
>>> sys.path.append("E:\\Project\\Python\\ModuleAndPackage2")
>>> sys.path
['', 'E:\\Project\\Python\\ModuleAndPackage', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python\\DLLs', 'C:\\Python\\lib', 'C:\\Python\\lib\\plat-win', 'C:\\Python\\lib\\lib-tk', 'C:\\Python', 'C:\\Python\\lib\\site-packages', 'E:\\Project\\Python\\ModuleAndPackage2']
>>>
# -*- coding: utf-8 -*- ID = 1 name = "This person" print namedef say(something): print name,'says', something
Python E:/Project/Python/ModuleAndPackage/person.py
C:\Users\Administrator>python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import person
This person>>> person.say("hello")
This person says hello
>>> print person.nameThis person>>>
# -*- coding: utf-8 -*- ID = 2 name = "This pet" print namedef run(somewhere): print name,'runs', somewhere
>>> import animal.pet
This pet>>> print animal.pet.name
This pet>>> animal.pet.run("everywhere")This pet runs everywhere>>>
>>> from animal.pet import name,run
>>> print name
This pet>>> run("everywhere")
This pet runs everywhere
>>>
# -*- coding: utf-8 -*- ID = 1 name = "This person" print name def say(something): print name,'says', something from animal.pet import name as pet_name, run as pet_run def have(): print name,'has', pet_name
>>> import person This person This pet >>> print person.name This person >>> print person.pet_name This pet >>> person.have() This person has This pet >>>
from animal.pet import *
>>> import person This person This pet >>> print person.name This pet
# -*- coding: utf-8 -*- __all__ = ['ID','run'] ID = 2 name = "This pet" print name def run(somewhere): print name,'runs', somewhere
>>> import person
This person
This pet
>>> print person.name
This person
>>> person.run("nowhere")
This pet runs nowhere
>>>
print "__init__" from pet import name as pet_name, run as pet_run#from animal.pet import name as pet_name, run as pet_run #from .pet import name as pet_name, run as pet_run
# -*- coding: utf-8 -*- ID = 1 name = "This person" print name def say(something): print name,'says', something import animal def have(): print name,'has', pet_name
>>> import person
This person
__init__
This pet
>>> dir(person)
['ID', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'have',
'name', 'pet', 'pet_name', 'pet_run', 'say']
>>> print person.pet_name
This pet
>>> person.pet_run("nowhere")
This pet runs nowhere
>>>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有