Python的私有变量

阅读 58

2022-08-02


1.Python中的实例不可以访问类的私有变量

'''Python正则实例'''
import re

c=re.match("www","www.baidu.com") #在起始位置匹配

print(c.span())

d=re.match("com","www.baidu.com") #不在起始位置匹配

print(d)


lines="Cat are small than dogs"
d=re.match(r"(.*)are (.*?) .*",lines, re.I|re.M) #只有有括号的情况,才可以使用group()里面加数字才有效用
print(d.group(2))

精彩评论(0)

0 0 举报