1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > python里使用正则表达式搜索单词

python里使用正则表达式搜索单词

时间:2019-04-23 21:20:32

相关推荐

python里使用正则表达式搜索单词

在python里有强大的正则表达式模块re,用来它进行模式匹配是非常方便的,比如下面的例子,就是用来从一段文字里查找一个单词,如下:

import repattern = 'this'text = '/caimouse is great, this is great way!'match = re.search(pattern, text)s = match.start()e = match.end()print('Found "{}"\nin "{}"\nfrom {} to {} ("{}")'.format(match.re.pattern, match.string, s, e, text[s:e]))

结果输出如下:

Found "this"

in "/caimouse is great, this is great way!"

from 40 to 44 ("this")

在这里使用start()表示匹配的开始位置,end()表示结束位置。

Python游戏开发入门

/course/detail/5690

你也能动手修改C编译器

/course/detail/5582

纸牌游戏开发

/course/detail/5538

五子棋游戏开发

/course/detail/5487

RPG游戏从入门到精通

/course/detail/5246

WiX安装工具的使用

/course/detail/5207

俄罗斯方块游戏开发

/course/detail/5110

boost库入门基础

/course/detail/5029

Arduino入门基础

/course/detail/4931

Unity5.x游戏基础入门

/course/detail/4810

TensorFlow API攻略

/course/detail/4495

TensorFlow入门基本教程

/course/detail/4369

C++标准模板库从入门到精通

/course/detail/3324

跟老菜鸟学C++

/course/detail/2901

跟老菜鸟学python

/course/detail/2592

在VC里学会使用tinyxml库

/course/detail/2590

在Windows下SVN的版本管理与实战

/course/detail/2579

Visual Studio 开发C++程序的基本使用

/course/detail/2570

在VC里使用protobuf协议

/course/detail/2582

在VC里学会使用MySQL数据库

/course/detail/2672

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。