Commit 54e6f94d by yangpengflag

update homework

parent 455f18cd
......@@ -18,10 +18,10 @@ def bubbleSort(nums,isAsc):
A=[3,4,2,22,7,8]
bubbleSort(A,isAsc=True)
bubbleSort(nums=A,isAsc=True)
print(A)
bubbleSort(A,isAsc=False)
bubbleSort(nums=A,isAsc=False)
print(A)
import re
def question_and_answer():
while True:
a = input("")
if (("贪心" or "贪心学院") and "做什么"in a):
print("贪心学院是一家高端重视售后服务的在线教育培训机构")
if "bye" in a:
print("拜拜,回聊!")
a = input("请输入您的问题:")
if ((("贪心" or "贪心学院") and ("做什么"))in a):
print("贪心学院是一家高端重视售后服务的在线教育培训机构") # 贪心学院是做什么的?
if "数字" in a: # 42197393里包含几个数字啊?
l = re.findall("\d", a)
print("%d个" %len(l))
if "手机号" in a: # 下边的号码中,哪些是手机号呢:18475309876,18719462345,17665148777,13332839908,12398028761
reg = "13\d{9}|14[579]\d{8}|15[^4\D]\d{8}|17[^49\D]\d{8}|18\d{9}"
reg1 = "1[3,4,5,7,8]\d{9}"
reg2 ="13[0-9]\d{8}|14[5,7]\d{8}|15[0-3,5-9]\d{8}|17[0-3,5-8]\d{8}|18[0-9]\d{8}|166\d{8}|19[8-9]\d{8}"
print(re.findall(reg, a))
print(re.findall(reg1,a))
print(re.findall(reg2,a))
if "ip" or "IP" in a: # 1324.231.432.1234,192.168.1.6,10.25.11.8这些信息中,哪些是ip呢?
reg_ip = "[\d]+\.[\d]+\.[\d]+\.[\d]+"
reg_ip1 = "[0-2]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}"
print(re.findall(reg_ip, a))
print(re.findall(reg_ip1, a))
else:
continue
if ("bye" or "拜拜" or "再见") in a:
print("再见!")
break
question_and_answer()
\ No newline at end of file
question_and_answer()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment