正则表达式库re是非常重要的一个库。

首先正则表达式有两种表示类型,一种是raw string类型(原生字符串类型),也就是我们经常看到的r'  '的写法,另一种是不带r的写法,称为string类型。raw string的作用是把转义字符当做普通的字符,所以一般来说,我们都是使用raw string类型,这样会更为方便。

接下来介绍re库的主要方法:

1、re.search()

2、re.match()

3、re.findall()

4、re.split()

5、re.finditer()

6、re.sub()

7、re.compiler()使用

在上面的方法中,有些方法返回的是match对象,那么什么是match对象呢?

match对象的属性有如下:

match对象的方法有如下:

python学习之re库的更多相关文章

  1. Python学习day45-数据库(总结)

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

  2. Python学习day44-数据库(单表及多表查询)

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

  3. Python学习day43-数据库(多表关系)

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

  4. Python学习day42-数据库的基本操作(1)

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

  5. Python学习day41-数据库(1)

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

  6. python学习之----lxml库和HTML parser

    lxml 这个库(http://lxml.de/)可以用来解析HTML 和XML 文档,以非常底层的实现而闻名 于世,大部分源代码是用C 语言写的.虽然学习它需要花一些时间(其实学习曲线越 陡峭,表明 ...

  7. Python学习--23 第三方库

    本文将介绍python里常用的模块.如未特殊说明,所有示例均以python3.4为例: $ python -V Python 3.4.3 网络请求 urllib urllib提供了一系列用于操作URL ...

  8. 从0开始的Python学习017Python标准库

    简介 Python标准库使随着Python附带安装的,它包含很多有用的模块.所以对一个Python开发者来说,熟悉Python标准库是十分重要的.通过这些库中的模块,可以解决你的大部分问题. sys模 ...

  9. python学习笔记——urllib库中的parse

    1 urllib.parse urllib 库中包含有如下内容 Package contents error parse request response robotparser 其中urllib.p ...

  10. 【Python学习】request库

    Requests库(https://www.python-requests.org/)是一个擅长处理那些复杂的HTTP请求.cookie.header(响应头和请求头)等内容的Python第三方库. ...

随机推荐

  1. USB接口案例——多态和转型

    其中,为传递和使用的匿名对象,即创建了对象,但是没有引用类和对象名来接收: 电脑类中的操作usb的成员方法中,要向下转型,毛主席讲的具体问题具体分析,不同的设备有不同的操作:

  2. 75.Java异常处理机制throws

    package testDate; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IO ...

  3. PDF文档导出

    代码如下: /// <summary> /// 获取html内容,转成PDF(注册) /// </summary> public void DownloadPDFByHTML( ...

  4. sass中的循环判断条件语句

    @if $lte7:true !default;//是否兼容ie6,7 //inline-block //ie6-7 *display: inline;*zoom:1; @mixin inline-b ...

  5. html介绍和head标签

      一.web标准 web准备介绍: w3c:万维网联盟组织,用来制定web标准的机构(组织) web标准:制作网页遵循的规范 web准备规范的分类:结构标准.表现标准.行为标准. 结构:html.表 ...

  6. 文件IO流

    //字节流读写含有中文的文本文件会出现问题,我在实践中居然没有检验出该问题,新人小菜,希望大家能指出: import java.io.FileInputStream; import java.io.F ...

  7. 算法竞赛入门经典训练指南——UVA 11300 preading the Wealth

    A Communist regime is trying to redistribute wealth in a village. They have have decided to sit ever ...

  8. m3u8文件下载合并的一种方法

    # -*- coding: utf-8 -*- """ Created on Wed Mar 14 15:09:14 2018 @author: Y "&quo ...

  9. Linux centos7下php安装cphalcon扩展的方法

    说明: 操作系统:CentOS7 php安装目录:/usr/local/php php.ini配置文件路径:/usr/local/php/etc/php.ini 运行环境:LNMP ,PHP7 .安装 ...

  10. Golang 数组和字符串之间的相互转换[]byte/string

    package main import ( "fmt" ) func main() { str := "hello" arr := []byte(str) fm ...