From 54e6f94d88ead92281a8dff18c3cbe4165e9fce1 Mon Sep 17 00:00:00 2001 From: yangpengflag <38930516+yangpengflag@users.noreply.github.com> Date: Tue, 8 Jan 2019 19:16:23 +0800 Subject: [PATCH] update homework --- 2_homework_bubbleSort.py | 4 ++-- 2_homework_question_and_answer.py | 47 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/2_homework_bubbleSort.py b/2_homework_bubbleSort.py index fa9d581..e9eb7af 100644 --- a/2_homework_bubbleSort.py +++ b/2_homework_bubbleSort.py @@ -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) diff --git a/2_homework_question_and_answer.py b/2_homework_question_and_answer.py index 69fa3dd..3739ded 100644 --- a/2_homework_question_and_answer.py +++ b/2_homework_question_and_answer.py @@ -1,11 +1,46 @@ +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() + + + -- libgit2 0.26.0