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...) 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).

(?

(?(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有多少种模块_python如何查看有哪些模块相关推荐

  1. python使用osgeo库_Python使用内置urllib模块或第三方库requests访问网络资源

    前言 更多内容,请访问我的 个人博客. Python 访问网络资源有很多方法,urllib, urllib2, urllib3, httplib, httplib2, requests ,现介绍如下两 ...

  2. python巩固函数和模块_Python学习教程6:函数,模块和类的使用

    Python函数 定义 函数是组织好的,可重复利用的,用来实现单一,或相关联功能的代码片段. 函数能提高应用的模块行,使代码逻辑更加的条理清晰. 内建函数 内建函数是Python中自带的,可供用户重复 ...

  3. python比较日期大小_Python日期的处理——datetime模块

    本文作者:胡   婧 文字编辑:杨慧琳 技术总编:张学人 好消息!!!爬虫俱乐部将于2019年7月5日至7月8日在武汉举行首期Python编程技术定制培训.本次培训采用理论与案例相结合的方式,旨在帮助 ...

  4. python解析xml选用什么模块_python 解析xml需要什么模块

    Python的标准库中,提供了6种可以用于处理XML的包. (1)xml.dom xml.dom实现的是W3C制定的DOM API.如果你习惯于使用DOM API或者有人要求这这样做,可以使用这个包. ...

  5. python爬虫需要调用什么模块_python爬虫需要调用什么模块

    python 爬虫常用模块: Python标准库--urllib模块 功能:打开URL和http协议之类 注:python 3.x中urllib库和urilib2库合并成了urllib库. 其中url ...

  6. python 文件操作的模块_Python之文件操作修改模块

    1.使用OS模块进行path路径操作 操作的语法为os.path.方法名(): import os # 首先导入os模块 *abspath()方法:获取当前文件的全路径,所带参数为file: file ...

  7. python解析html xml最好的模块_python中处理xml的模块哪个好?

    python中可以使用BeautifulSoup4或pyQuery模块处理xml文件.pyQuery模块比较适合于对CSS选择器等的支持,BeautifulSoup4模块使用简单. Beautiful ...

  8. math库是python语言的数学模块_Python入门-函数库(模块)

    内建函数和异常 定义内建函数(例如 len,int, range ...)的 _ _builtin_ _ 模块, 以及定义所有内建异常的 exceptions模块. Python 在启动时导入这两个模 ...

  9. 使用python处理wps表格_python中常⽤的excel模块库

    python中常用的excel模块库&安装方法 openpyxlopenpyxl是⼀个Python库,用于读取/写⼊Excel 2010 xlsx / xlsm / xltx / xltm⽂件 ...

最新文章

  1. 全网最经典26道Spring面试题总结,附面试题答案
  2. python提取英文单词 每行显示一个_使用python对文件中的单词进行提取
  3. Dubbo3.0 简介
  4. 【Mac Buf Install Solution】Mac Buf Not Provide support for this old version Solution
  5. 3位黑洞发现者获2020年诺贝尔物理学奖
  6. Deploy Office Communications Server 2007R2 Group Chat Server(一)
  7. SAS (Statistics Analysis System) 统计分析系统软件
  8. 【防爬虫01】通过headers中的user-agent字段来反爬
  9. 用自己的域名配置动态域名解析(DDNS)
  10. 'i' format requires -2147483648 = number = 2147483647
  11. CCF模拟题-1~5
  12. Android Studio出现APP闪退问题(My Application keeps stopping)
  13. 【微分方程数值解】常微分方程(一)欧拉方法和改进欧拉方法(附python算例,封装类)
  14. 华为od统一考试B卷【We Are A Team】C++ 实现
  15. Unity知识点总结(1)
  16. 计算机无法找到扫描仪和照相机,我的电脑不显示扫描仪和摄像头的原因及解决方法...
  17. 2020-MyBatis面试题
  18. 我和 JSRUN 网站的一些故事
  19. 【独立站运营】营销邮件被判定为垃圾邮件?四个方法教你避开
  20. linux--shell--crontab定义运行任务

热门文章

  1. GCC 生成的符号表调试信息剖析
  2. Vue.js 极简小例:读值、样式调用、if判断、a 标签、点击事件、管道
  3. Coolite动态加载CheckboxGroup,无法在后台中获取
  4. 设置Eclipse中的字符集为UTF-8
  5. Repeater的使用
  6. django模板系统(下)
  7. C3P0连接池工具类使用
  8. CAS单点登录配置[3]:服务器端配置
  9. 外籍主管眼中的阿里巴巴
  10. 【随感】tomorrow ,new semester ,finally i have time to read some books~