匹配分组
字符 | 功能 |
---|---|
| | 匹配左右任意一个表达式 |
(ab) | 将括号中字符作为一个分组 |
\num | 引用分组num匹配到的字符串 |
(?P<name>) | 分组起别名 |
(?P=name) | 引用别名为name分组匹配到的字符串 |
示例1: |
匹配左右任意一个表达式
ret = re.match("[1-9]?\d$|100","8")
print(ret.group()) # 8
答案:
8;
78;
示例2()
将括号中字符作为一个分组
/w:匹配单词字符,即a-z、A-Z、0-9、_
import re
ret = re.match("\w{4,20}@163\.com", "test@163.com")
print(ret.group()) # test@163.com
ret = re.match("\w{4,20}@(163|126|qq)\.com", "test@126.com")
print(ret.group()) # test@126.com
示例3:\
:引用分组num匹配到的字符串
*无限或0次
ret = re.match("<[a-zA-Z]*>\w*</[a-zA-Z]*>", "<html>hh</html>")
print(ret.group())
示例4 (?P)
(?P=name)
分组起别名
引用别名为name分组匹配到的字符串
import re
ret = re.match(r"<(?P<name1>\w*)><(?P<name2>\w*)>.*</(?P=name2)></(?P=name1)>", "<html><h1>www.hpedu.cn</h1></html>")
print(ret.group())
search方法
import re
ret = re.search("\d+", "阅读次数为 9999")
ret.group()
findall方法
import re
ret = re.findall(r"\d+", "python = 9999, c = 7890, c++ = 12345")
print(ret)
sub 将匹配到的数据进行替换
import re
ret = re.sub(r"\d+", '998', "python = 997")
print(ret)
split 根据匹配进行切割字符串,并返回一个列表
import re
ret = re.split(r":| ","info:xiaoZhang 33 shandong")
print(ret)
css 圆角
设置四个角为圆角
border-radius:半径
分别设置四个角的弧度,写出格式
border-radius:30px 40px 50px 60px;
设置右下角的弧度为30px
border-bottom-right-radius: 30px;
border-Y轴位置单词-X轴位置单词-radius:半径
设置一个红色背景颜色,透明度为六成透明
background-color: rgba(255,0,0,0.6)
语法
设置四个角的
border-radius: 半径
<style>
div{
width: 300px;
height: 300px;
background-color: red;
border-radius:150px;
}
div{
width: 300px;
height: 300px;
background-color: red;
border-radius:20px 30px 50px 90px;
}
</style>
单独的设置每一个角的弧度
border-Y轴位置英文-X轴位置英文-radius:半径
<style>
div{
width: 300px;
height: 300px;
background-color: red;
border-bottom-right-radius:150px;
}
</style>
<div></div>
css的权重,请列出一万分,一千分,一百分,十分,一分这些权重分值所以应的样式
10000,!important
1000,内联样式
100,ID选择器
10,类与伪类选择器
1,标签选择器
0,其它选择器
<style>
.box{
background-color: blue;
}
div{
width: 300px;
height: 300px;
background-color: red !important;;
}
#outter{
background-color: yellow !important;
}
</style>
<div class="wrapper">
<div class="box" id="outter" style="background-color: green"></div>
</div>