- 三分钟热情自学 Python · 第10期 · Python 正
- 三分钟热情自学 Python · 第10期 · Python 正
- 盗字笔记——Python自学(19)
- 三分钟热情自学 Python · 第6期 · Python 列表
- 三分钟热情自学 Python · 第1期 · Python 安装
- 三分钟热情自学 Python · 第3期 · Python 基础
- 三分钟热情自学 Python · 第5期 · Python 函数
- 三分钟热情自学 Python · 第7期 · Python 字典
- 三分钟热情自学 Python · 第2期 · Python 入门
- 三分钟热情自学 Python · 第4期 · Python 语句
千淘万漉虽辛苦,吹尽狂沙始到金。
——刘禹锡

1. 前言
在这个生活中处处都是大数据和人工智能的时代,总是能在各种角落看到 Python 的培训广告。我招架不住敌方的猛烈攻势,败下阵来。经过了一分钟的深思熟虑,我决定利用我的三分钟热情进行回击,从零开始自学 Python。
本期要学习的正则表达式颇有些难度,如果要用一个词来形容它,那非人类语言就再恰当不过了。因此本期我就蜻蜓点水式地学习一下,等以后再回过头来好好学习这一块。
2.
Regular Expressions
正则表达式
A regular expression is a group of characters or symbols which is used to find a specific pattern in a text.
正则表达式是由字母和符号组成的一组字符,它可以用来从文本中找出符合某种模式的字符串。
2.1
Steps to Using Regular Expressions in Python
在 Python 中使用正则表达式的步骤
-
Import the regex module with
import re
.使用
import re
引入正则表达式模块。In Python, you need to import the
re
module first to creating aRegex
object. Otherwise, you'll get a NameError: name 're' is not defined error message.
在 Python 中,需要先引入 re
模块才能创建 Regex
对象。否则将会得到报错信息:“NameError: name 're' is not defined error message”。
网友评论