Python模块和模块引用(一)
"""
import my_module as mm
courses = ['History','Math','Physics','CompSci']
index = mm.find_index(courses, 'Math')
print (index)
"""
"""
from my_module import find_index
courses = ['History','Math','Physics','CompSci']
index = find_index(courses, 'Math')
print (index)
"""
"""
from my_module import find_index as fi, test
courses = ['History','Math','Physics','CompSci']
index = fi(courses, 'Math')
print (index)
print(test)
"""
"""
from my_module import *
courses = ['History','Math','Physics','CompSci']
index = find_index(courses, 'Math')
print (index)
print(test)
"""
'''
from my_module import find_index, test
import sys
courses = ['History','Math','Physics','CompSci']
index = find_index(courses, 'Math')
print(sys.path) # print out list of directories imported
'''
'''
Imported my_module...
['/Users/Yao/python_learn', #this directory was added automatically
'/Users/Yao/Documents',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages']
'''
'''
import sys
sys.path.append('Users/...') # add director for importing modules
'''
Python模块和模块引用(一)的更多相关文章
- Python 模块之间的引用
项目结构: Dog.Cat模块引用Animal模块 Animal模块代码: # -*- coding:UTF-8 -*- # 定义一个动物类 class Animal(object): def run ...
- python基础——使用模块
python基础——使用模块 Python本身就内置了很多非常有用的模块,只要安装完毕,这些模块就可以立刻使用. 我们以内建的sys模块为例,编写一个hello的模块: #!/usr/bin/env ...
- Python之路-python(常用模块学习)
模块介绍 time &datetime模块 random os sys shutil shelve xml处理 yaml处理 configparser hashlib re正则表达式 1.模块 ...
- Python类、模块、包的区别
类 类的概念在许多语言中出现,很容易理解.它将数据和操作进行封装,以便将来的复用. 模块 模块,在Python可理解为对应于一个文件.在创建了一个脚本文件后,定义了某些函数和变量.你在其他需要这些功能 ...
- python正则表达式——re模块
http://blog.csdn.net/zm2714/article/details/8016323 re模块 开始使用re Python通过re模块提供对正则表达式的支持.使用re的一般步骤是先将 ...
- Python的模块,模块的使用、安装,别名,作用域等概念
所谓的模块就是将不同功能的函数分别放到不同的文件中,这样不仅有利于函数的维护,也方便了函数的调用.在Python中,一个.py文件就是一个模块(Module). 在模块的上层有一个叫做包(Packag ...
- Python进阶之模块与包
模块 .note-content {font-family: "Helvetica Neue",Arial,"Hiragino Sans GB","S ...
- Python中的模块介绍和使用
在Python中有一个概念叫做模块(module),这个和C语言中的头文件以及Java中的包很类似,比如在Python中要调用sqrt函数,必须用import关键字引入math这个模块,下面就来了解一 ...
- python有三种导入模块的方法(转)
原文:http://www.cnblogs.com/allenblogs/archive/2011/11/15/2055149.html python有三种导入模块的方法 其一, import mod ...
- Python系列之模块、和字符串格式化
Python 模块 模块让你能够有逻辑地组织你的Python代码段. 把相关的代码分配到一个 模块里能让你的代码更好用,更易懂. 模块也是Python对象,具有随机的名字属性用来绑定或引用. 模块分为 ...
随机推荐
- LeetCode--Longest Consecutive Sequence(最长连续序列) Python
题目描述: Longest Consecutive Sequence(最长连续序列) 中文: 给定一个未排序的整数数组,找出最长连续序列的长度. 要求算法的时间复杂度为 O(n). 英文: Given ...
- Application对象详解
定义// import javax.servlet.ServletContext;// ServletContext类:用于表示应用程序的上下文// 取得application对象ServletCon ...
- c++ fork进程与同步锁
首先定义在多进程环境中的锁,采用读写锁,即可以同时读,但只能单独写. 头文件processLock.h #ifndef PROCESSLOCK_H #define PROCESSLOCK_H #inc ...
- centos 安装mysql冲突解决方法
[root@centos-50 servers]# rpm -ivh mysql-server-5.5.33-1.linux2.6.x86_64.rpm Preparing... ########## ...
- UNP学习第五章(二)
一.POSIX信号处理 信号:告知某进程发生了某个事件的通知(软中断),通常是异步的. 信号可以:由进程发给另一个进程,由内核发给某个进程. 设置信号处理办法,有三个选择: 1.写一个函数,在信号发生 ...
- 微信小程序学习笔记(二)--框架-全局及页面配置
描述和功能 框架提供了自己的视图层描述语言 WXML 和 WXSS,以及基于 JavaScript 的逻辑层框架,并在视图层与逻辑层间提供了数据传输和事件系统,让开发者能够专注于数据与逻辑. 响应的数 ...
- 前端每日实战:57# 视频演示如何用纯 CSS 创作一双黑暗中的眼睛
效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/xzYVzO 可交互视频 此视频是可 ...
- 安装纯净版debian!
kali更新了1.1.0a,不知道新版的内核哪地方有bug,用着用着就卡死了,一怒之下卸载了装debian. 下载的netinst只有200M,基本上就是刚好能用,不要用硬盘装,会找不到网卡,无线也没 ...
- 54、tensorflow手写识别的高级版本
''' Created on 2017年3月4日 @author: weizhen ''' import tensorflow as tf def weight_variable(shape): in ...
- SecureCRT key登录linux ssh设置
一.首先用secureCrt创建密钥 1.使用SecureCRT创建私钥和公钥. SecureCRT quick Connect-> Authentiation -> Public Key ...