python合法关键字是_python练习题-day18
1、匹配一行文字中的所有開頭的字母內(nèi)容
import re
s="i love you not because of who you are, but because of who i am when i am with you"
import re
content=re.findall(r"\b\w",s)
print(content)
2、匹配一行文字中的所有開頭的數(shù)字內(nèi)容
import re
s="i love you not because 12sd 34er 56df e4 54434"
import re
s="i love you not because 12sd 34er 56df e4 54434"
ret=re.findall(r"\b\d+",s)
print(ret)
3、匹配一行文字中的所有開頭的數(shù)字內(nèi)容或字母內(nèi)容123sdf
s="123sdf"
import re
content=re.search("\w",s).group()
print(s)
4、只匹配包含字母和數(shù)字的行
s="i love you not because\n12sd 34er 56\ndf e4 54434"
content=re.findall(r"\w+",s,re.M)
5、寫一個正則表達(dá)式,使其能同時識別下面所有的字符串:'bat', 'bit', 'but', 'hat', 'hit', 'hut‘
import re
s="'bat', 'bit', 'but', 'hat', 'hit', 'hut"
#方法一
s="'bat', 'bit', 'but', 'hat', 'hit', 'hut"
import re
content=re.findall("\w+",s)
print(content)
#方法二
content=re.findall("..t",s)
print(content)
6、匹配所有合法的python標(biāo)識符
#coding=utf-8
import re
s="awoeur awier !@# @#4_-asdf3$^&()+?>
s="awoeur awier !@# @#4_-asdf3$^&()+?>
import re
content=re.findall(".*",s,re.S)
print(content)
7、提取每行中完整的年月日和時間字段
#coding=utf-8
import re
s="""se234 1987-02-09 07:30:00
1987-02-10 07:25:00"""
content=re.findall("\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}",s)
print(content)
8、將每行中的電子郵件地址替換為你自己的電子郵件地址
#coding=utf-8
import re
s="""693152032@qq.com, werksdf@163.com, sdf@sina.com
sfjsdf@139.com, soifsdfj@134.com
pwoeir423@123.com"""
import re
content=re.subn("\w+@\w+.com","test@qq.com",s)
print(content,type(content))
9、匹配\home關(guān)鍵字,s="skjdfoijower \home?? \homewer"
s="skjdfoijower \home \homewer"
import re
content=re.findall(r"\\home",s)
print(content)
10、使用正則提取出字符串中的單詞s="""i love you not because of who 234 you are, 234 but 3234ser because of who i am when i am with you"""
import re
content=re.findall(r"\b[a-z]+",s,re.I)
print(content)
11、使用正則表達(dá)式匹配合法的郵件地址:
import re
s="""xiasd@163.com, sdlfkj@.com sdflkj@180.com solodfdsf@123.com sdlfjxiaori@139.com saldkfj.com oisdfo@.sodf.com.com"""
import re
content=re.findall("\w+@\w+.com",s)
print(content)
12、去除以下html文件中的標(biāo)簽,只顯示文本信息。
崗位職責(zé):
完成推薦算法、數(shù)據(jù)統(tǒng)計、接口、后臺等服務(wù)器端相關(guān)工作
必備要求:
良好的自我驅(qū)動力和職業(yè)素養(yǎng),工作積極主動、結(jié)果導(dǎo)向
技術(shù)要求:
1、一年以上 Python 開發(fā)經(jīng)驗,掌握面向?qū)ο蠓治龊驮O(shè)計,了解設(shè)計模式
2、掌握HTTP協(xié)議,熟悉MVC、MVVM等概念以及相關(guān)WEB開發(fā)框架
3、掌握關(guān)系數(shù)據(jù)庫開發(fā)設(shè)計,掌握 SQL,熟練使用 MySQL/PostgreSQL 中的一種
4、掌握NoSQL、MQ,熟練使用對應(yīng)技術(shù)解決方案
5、熟悉 Javascript/CSS/HTML5,JQuery、React、Vue.js
加分項:
大數(shù)據(jù),數(shù)理統(tǒng)計,機(jī)器學(xué)習(xí),sklearn,高性能,大并發(fā)。
import re
content=re.sub("?\w+>| "," ",s)
print(content)
13、將以下網(wǎng)址提取出域名:
http://www.interoem.com/messageinfo.asp?id=35`
http://3995503.com/class/class09/news_show.asp?id=14
http://lib.wzmc.edu.cn/news/onews.asp?id=769
http://www.zy-ls.com/alfx.asp?newsid=377&id=6
http://www.fincm.com/newslist.asp?id=415
p = r"(http://.+?/).+"
print(re.sub(p, lambda x : x.group(1), s2))
標(biāo)簽:練習(xí)題,python,com,content,re,print,import,day18,findall
總結(jié)
以上是生活随笔為你收集整理的python合法关键字是_python练习题-day18的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 车载安卓导航一键root_听说比Carp
- 下一篇: python不退出运行页面_如何在不完全