python模块导入的方法
作者:半屯澜湾 时间:2023-08-23 06:54:38
模块在python编程中的地位举足轻重,熟练运用模块可以大大减少代码量,以最少的代码实现复杂的功能。
下面介绍一下在python编程中如何导入模块:
(1)import 模块名:直接导入,这里导入模块中的所有与函数;
import configparser
import time
import sys
这里的模块也可以是自己编写的脚本名称,如:
#hello.py
def hello1():
print("hello world!")
import hello
(2) from 模块名 import 函数名1[,函数名2,...] : 导入函数中的特定函数;
from requests import get
from requests import post
from platform import systey
(3)from 模块名 import *:导入所有函数, * 代表所有函数;
from wxpy import *
(4)import 模块名 as 别名:别名导入;
import configparser as cf
import time as T
import sys as sy
来源:https://www.cnblogs.com/xiaoyan-ipython/p/11729693.html
标签:python,模块导入
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python生成随机验证码代码实例解析
2023-08-28 20:48:58
python编程实现希尔排序
2022-11-05 22:21:57
![](https://img.aspxhome.com/file/2023/3/102763_0s.jpg)
Python fileinput模块使用介绍
2023-08-22 14:32:12
详解Python数据结构与算法中的顺序表
2023-12-31 01:47:04
![](https://img.aspxhome.com/file/2023/2/115142_0s.png)
深入浅析python定时杀进程
2021-10-23 17:14:15
mysql 修改表结构 判断并添加column
2010-10-25 20:07:00
SQL的substring_index()用法实例(MySQL字符串截取)
2024-01-27 19:30:19
Python 函数那不为人知的一面
2022-09-24 10:03:31
![](https://img.aspxhome.com/file/2023/3/101063_0s.jpg)
linux ubuntu中安装、卸载和删除python-igraph的方法教程
2021-01-10 19:54:02
Python中利用aiohttp制作异步爬虫及简单应用
2023-07-21 04:50:40
![](https://img.aspxhome.com/file/2023/6/135286_0s.png)
Golang中channel的原理解读(推荐)
2024-02-08 15:41:38
![](https://img.aspxhome.com/file/2023/9/108079_0s.jpg)
pytorch之torchvision.transforms图像变换实例
2021-05-19 05:44:05
Go语言基础数组用法及示例详解
2024-04-26 17:33:52
![](https://img.aspxhome.com/file/2023/6/133976_0s.png)
关于python中remove的一些坑小结
2022-09-22 02:14:31
![](https://img.aspxhome.com/file/2023/6/118626_0s.png)
SQL Server 2008主要功能在兼容性上的问题
2009-03-25 16:43:00
微信小程序MUI导航栏透明渐变功能示例(通过改变opacity实现)
2024-05-11 09:42:26
![](https://img.aspxhome.com/file/2023/6/125946_0s.gif)
Hive-SQL查询连续活跃登录用户思路详解
2024-01-22 08:29:47
![](https://img.aspxhome.com/file/2023/2/113552_0s.png)
简单了解python的内存管理机制
2021-10-03 18:13:11
Golang CSP并发机制及使用模型
2023-09-15 16:13:27
![](https://img.aspxhome.com/file/2023/4/101674_0s.jpg)
Python实现获取视频时长功能
2021-11-25 03:33:57
![](https://img.aspxhome.com/file/2023/0/80420_0s.png)