```
import keyword
import re
url = "www.baidu.com"
# 匹配包含www的字符串
re_compile = re.compile("www")
# match从起始位置开始匹配,且只匹配一次,如果不没找到,则返回None
match = re_compile.match(url)
# .span用来获取匹配到的字符串所对应的下标位置
#re_compile.match(url).span()
# match返回的是match对象,获取值使用group
print(match.group())
import re
line = "Cats are smarter than dogs"
# .* 表示任意匹配除换行符(\n、\r)之外的任何单个或多个字符
matchObj = re.match(r'(.*) are (.*) .*', line, re.M | re.I)
if matchObj:
print("matchObj.group() : ", matchObj.group())
print("matchObj.group(1) : ", matchObj.group(1))
print("matchObj.group(2) : ", matchObj.group(2))
else:
print("No match!!")
class switch_case(object):
def case_to_function(self, case):
fun_name = "case_fun_" + str(case)
method = getattr(self, fun_name, self.case_fun_other)
return method
def case_fun_1(self, msg):
print(msg)
def case_fun_2(self, msg):
print(msg)
def case_fun_other(self, msg):
print(msg)
```
```
import keyword
table = ["def","set","len","input","print"]
new =""
temp =""
file = open("6183.py","r",encoding="utf-8")
conent = file.read()
#print(conent)
file.close()
for ch in conent:
if ch.isalpha():
#i1 = i.upper()
temp += ch
#print(temp)
else:
print(temp)
if(not keyword.iskeyword(temp)) and (temp not in table):
temp = temp.upper()
new += temp
new += ch
temp = ''
#temp += i
#print(new)
newfile = open("6184.py","w",encoding="utf-8")
newfile.write(new)
newfile.close()
```
```
def judge(n):
m =set(n)
if len(m) != len(n):
return True
else:
return False
line = input("请输入一串列表值:")
print(judge(line))
```
```
def JUDGE(N):
M =set(N)
if len(M) != len(N):
return True
else:
return False
LINE = input("请输入一串列表值:")
print(JUDGE(LINE))
```
```
def JUDGE(N):
M =set(N)
if len(M) != len(N):
return True
else:
return False
LINE = input("请输入一串列表值:")
print(JUDGE(LINE))
```
```
import keyword
temp = 'return'
a = not keyword.iskeyword(temp)
#print(a)
b = ['set']
c = temp not in b
#print(c)
print(temp.upper())
```
- py转exe
- py服务器
- py登录
- py查询
- 爬TB热卖1017
- 爬TB分类1015
- 爬BD文库1010
- 爬文库924
- json917
- decode912
- 转码910
- radians829
- turtle827
- 画叶子820
- 树干815
- Turtle, mainloop718
- sorted716
- random711
- turtle.colormode709
- abs704
- begin_fill702
- randint,random627
- isalpha625
- keyword620
- compile618
- judge613
- list1.copy611
- random.choice606
- format_randint604
- save_csv528
- jieba523
- wordcloud521
- wordcloud516
- jieba.lcut514
- counts503
- format423
- 花瓣418
- strftime416
- turtle.fillcolor411
- random.random409
- pensize404
- 花蕊328
- input327
- eval_float320
- open319
- while314
- JCR影响因子313
- _to_chinese4_312
- encoding306
- read305
- flask1029