python合法关键字是_python练习题-day18
1、匹配一行文字中的所有開頭的字母內容
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、匹配一行文字中的所有開頭的數字內容
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、匹配一行文字中的所有開頭的數字內容或字母內容123sdf
s="123sdf"
import re
content=re.search("\w",s).group()
print(s)
4、只匹配包含字母和數字的行
s="i love you not because\n12sd 34er 56\ndf e4 54434"
content=re.findall(r"\w+",s,re.M)
5、寫一個正則表達式,使其能同時識別下面所有的字符串:'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標識符
#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關鍵字,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、使用正則表達式匹配合法的郵件地址:
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文件中的標簽,只顯示文本信息。
崗位職責:
完成推薦算法、數據統計、接口、后臺等服務器端相關工作
必備要求:
良好的自我驅動力和職業素養,工作積極主動、結果導向
技術要求:
1、一年以上 Python 開發經驗,掌握面向對象分析和設計,了解設計模式
2、掌握HTTP協議,熟悉MVC、MVVM等概念以及相關WEB開發框架
3、掌握關系數據庫開發設計,掌握 SQL,熟練使用 MySQL/PostgreSQL 中的一種
4、掌握NoSQL、MQ,熟練使用對應技術解決方案
5、熟悉 Javascript/CSS/HTML5,JQuery、React、Vue.js
加分項:
大數據,數理統計,機器學習,sklearn,高性能,大并發。
import re
content=re.sub("?\w+>| "," ",s)
print(content)
13、將以下網址提取出域名:
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))
標簽:練習題,python,com,content,re,print,import,day18,findall
總結
以上是生活随笔為你收集整理的python合法关键字是_python练习题-day18的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 车载安卓导航一键root_听说比Carp
- 下一篇: python不退出运行页面_如何在不完全