python如何查看有哪些模块
Question:
如何查看正则表达式模块re及其相关函数的意义
1、终端命令行下
python
>> import sys
>> sys.modules
###################################
一长串信息中字段modules对应的模块即为包含的模块。
###################################
>> import re
>> help(re)
Help on module re: NAME
re - Support for regular expressions (RE). FILE
/usr/lib64/python2.7/re.py DESCRIPTION
This module provides regular expression matching operations similar to
those found in Perl. It supports both 8-bit and Unicode strings; both
the pattern and the strings being processed can contain null bytes and
characters outside the US ASCII range. Regular expressions can contain both special and ordinary characters.
Most ordinary characters, like "A", "a", or "0", are the simplest
regular expressions; they simply match themselves. You can
concatenate ordinary characters, so last matches the string 'last'. The special characters are:
"." Matches any character except a newline.
"^" Matches the start of the string.
"$" Matches the end of the string or just before the newline at
the end of the string.
"*" Matches 0 or more (greedy) repetitions of the preceding RE.
Greedy means that it will match as many repetitions as possible.
"+" Matches 1 or more (greedy) repetitions of the preceding RE.
"?" Matches 0 or 1 (greedy) of the preceding RE.
*?,+?,?? Non-greedy versions of the previous three special characters.
{m,n} Matches from m to n repetitions of the preceding RE.
{m,n}? Non-greedy version of the above.
"\\" Either escapes special characters or signals a special sequence.
[] Indicates a set of characters.
A "^" as the first character indicates a complementing set.
"|" A|B, creates an RE that will match either A or B.
(...) Matches the RE inside the parentheses.
The contents can be retrieved or matched later in the string.
(?iLmsux) Set the I, L, M, S, U, or X flag for the RE (see below).
(?:...) Non-grouping version of regular parentheses.
(?P<name>...) The substring matched by the group is accessible by name.
(?P=name) Matches the text matched earlier by the group named name.
(?#...) A comment; ignored.
(?=...) Matches if ... matches next, but doesn't consume the string.
(?!...) Matches if ... doesn't match next.
(?<=...) Matches if preceded by ... (must be fixed length).
(?<!...) Matches if not preceded by ... (must be fixed length).
(?(id/name)yes|no) Matches yes pattern if the group with id/name matched,
the (optional) no pattern otherwise.
>>> help(re.compile)
Help on function compile in module re: compile(pattern, flags=0)
Compile a regular expression pattern, returning a pattern object.
(END)
2、IDE环境下(待续……)
python如何查看有哪些模块的更多相关文章
- Linux下查看Python安装了哪些脚本模块
Linux下查看Python安装了哪些脚本模块 1.什么是rpm ? rpm 即RedHat Package Management,是RedHat的发明之一 .现在包括OpenLinux.fedora ...
- Python导入自定义包或模块
一般我们会将自己写的 Python 模块与 Python 自带的模块分开存放以达到便于维护的目的. Python 运行环境在查找模块时是对 sys.path 列表进行遍历,如果我们想在运行环境中添加自 ...
- python数据库操作之pymysql模块和sqlalchemy模块(项目必备)
pymysql pymsql是Python中操作MySQL的模块,其使用方法和MySQLdb几乎相同. 1.下载安装 pip3 install pymysql 2.操作数据库 (1).执行sql #! ...
- python运维开发(六)----模块续
内容目录 反射 模块 os模块 sys模块 md5加密模块 re正则匹配模块 configparse模块 xml模块 shutil模块 subprocess模块 反射 利用字符串的形式去对象(模块)中 ...
- python运维开发(五)----模块、生成器
内容目录 双层装饰器 字符串格式化 生成器和迭代器 递归 模块 双层装饰器 需求场景介绍: 现有用户登录系统,普通用户能查看自己相关信息的权限,管理员用户能查看所有用户的权限,可以做两个装饰器来实现需 ...
- Python 2.7 学习笔记 模块和包
我们来考虑下如下几种场景: 1.编写一个python程序,如果程序比较简单,则可以把代码放到一个python文件中.但如果程序功能比较多,可能需要多个python文件来组织源代码.而这些文件之间的代码 ...
- Python第五章__模块介绍,常用内置模块
Python第五章__模块介绍,常用内置模块 欢迎加入Linux_Python学习群 群号:478616847 目录: 模块与导入介绍 包的介绍 time &datetime模块 rando ...
- Python Docker 查看私有仓库镜像【转】
文章来源:python Docker 查看私有仓库镜像 pip 安装: # 首先安装epel扩展源: yum -y install epel-release # 更新完成之后,就可安装pip: yum ...
- Python 在cmd中import模块成功,但是在jupyter notebook中No module xxx found
由于需要用到python中的某个库,因此打开命令行窗口cmd,然后使用pip安装.安装成功后,在cmd中输入python调出python环境,import该模块并使用,可以正常使用.但是打开juypt ...
随机推荐
- win10 停留在启动画面
这是由于部分电脑的主板不支持快速启动造成的,所以把快速启动功能关闭掉即可.具体操作步骤如下:控制面板--硬件和声音--电源选项--选择电源按钮的功能--选择“更改当前不可用的设置”,然后把“启用快速启 ...
- SQL SERVER 2012/ 2014 分页,用 OFFSET,FETCH NEXT改写ROW_NUMBER的用法
写法: 假装有个表Shop,其中有一列ShopName,取100000到100050条数据. ROW_NUMBER 的写法 SELECT * FROM ( SELECT ShopName , ROW_ ...
- jenkins将构建成功或失败的信息发送给指定URL(eg: pomelo采用jenkins持续集成)
先提供一个思路供大家参考,想将构建成功或者失败的信息发送给指定URL的话,可以这样:1.A构建后触发另一个构建B,构建B执行某个插件2.插件的功能: (1)利用jenkins API获取构建A最 ...
- LinkedHashMap唯一,存储取出有序
package cn.itcast_03; import java.util.LinkedHashMap; import java.util.Set; /* * LinkedHashMap:是Map接 ...
- 并发基础(十) 线程局部副本ThreadLocal之正解
本文将介绍ThreadLocal的用法,并且指出大部分人对ThreadLocal 的误区. 先来看一下ThreadLocal的API: 1.构造方法摘要 ThreadLocal(): 创建一个线程 ...
- Jenkins配置HTML报告(Windows环境)
1.首先安装插件HTML Publisher,点击直接安装 2.在任务中配置,构建后操作,添加Publish HTML reports 3.添加完成后,新增一项 4.HTML directory to ...
- ORACLE常用数值函数、转换函数、字符串函数介绍
ORACLE常用数值函数.转换函数.字符串函数介绍. 数值函数: abs(m) m的绝对值 mod(m,n) m被n除后的余数 power(m,n) m的n次方 round(m[,n]) m四舍五入至 ...
- shiro 框架
惊天给大家总结一点shiro框架的小知识 Apache Shiro是一个强大且易用的Java安全框架,执行身份验证.授权.密码和会话管理.使用Shiro的易于理解的API,您可以快速.轻松地获得任何应 ...
- VBA 连接文本的自定义函数(可用于数组公式)
Function ConTxt(ParamArray args() As Variant) As VariantDim tmptext As Variant, i As Variant, cellv ...
- visual studio 2017 报错 无法下载安装文件。请检查Internet连接,然后重试
vs下载完离线安装包在无网络环境下点击安装时出现无法下载安装文件.请检查Internet连接,然后重试 原因是证书没有导 解决方法 打开刚刚存放离线文件的路径,比如D:\vs2017offline,然 ...