Python从模块导入函数
2016-10-23 14:38
267 查看
Python从模块导入函数
第一种
>>> import math >>> math.sqrt(4) 2.0
>>> import math as mymath >>> mymath.sqrt(4) 2.0
第二种
>>> from math import sqrt >>> sqrt(4) 2.0
>>> from math import sqrt as mysqrt >>> mysqrt(4) 2.0
>>> from math import sqrt,sin,tan
>>> from math import *
第三种
>>> mymath= __import__('math') >>> mymath.sqrt(4) 2.0
相关文章推荐
- Python定义函数,模块导入以及Python主程序文件结构
- python学习笔记(九)将函数存储在模块中,导入模块
- Python定义函数,模块导入以及Python主程序文件结构
- python 导入模块及函数使用
- python 知识点:反射 之 getattr()实现以字符串形式导入模块和执行函数
- Python 导入自定义模块函数,安装NLTK,导入精确计算
- Python模块函数导入
- Python基础:数据类型、变量定义、输入/输出、逻辑、函数/模块(导入)/类、异常处理
- Python3基础 创建一个模块 导入并调用其中的函数 主代码与模块代码在同一文件夹下
- python模块与包的了解,__name__的功能,包中函数的导入
- python 函数、模块、包及import导入方法
- python 函数、模块、包及import导入方法
- python导入模块,使用模块内函数,os,os.path
- Python中导入其它模块中的函数
- python 关于自定义 模块(类,函数),包的导入
- Dive Into Python 学习记录1-函数/模块导入/字典/列表/元组/字符串分割、连接、格式化/映射list/
- python 函数、模块、包及import导入方法
- python 模块导入问题详解
- [转]可爱的 Python:: 使用 itertools 模块中的组合函数
- Python中两种模块导入方法