#1.正则表达式计算 origin = "1 - 2 * ( ( 60 - 30 + ( -40.0 / 5 ) * ( 9 - 2 * 5 / 3 + 7 / 3 * 99 / 4 * 2998 + 10 * 568 / 14 )) - ( - 4 * 3 ) / ( 16 - 3 * 2))"
#2.将“我我我、、、我我、、我要、我要要、、、要要要、、要要、、学学学、、、、学学编、、、学编编编、、编编编程、、程程”还原成:我要学编程
f = "我我我、、、我我、、我要、我要要、、、要要要、、要要、、学学学、、、、学学编、、、学编编编、、编编编程、、程程"
c = ''
import re
a = re.sub(r'、','',f)
for i in a:
if i not in c:
c += i
print(c)
#3.查找IP地址
temp = "192.168.1.200 10.10.10.10 3.3.50.3 127.0.0.1 244.255.255.249 273.167.189.222"
# sel = re.compile(r'((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))')
# 参考:https://www.cnblogs.com/brogong/p/7929298.html
f = re.compile(r"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b")
ip = f.findall(temp)
print(ip)
#4.读写用户的输入,根据用户输入,创建一个相应的目录
improt os,sys
os.mkdir(sys.argv[1])
#5.进度条,显示百分比
import sys,time,datetime
#
for i in range(1,101):
if i == 100:
b = '完成'
else:
b = '进度中'
for a in ['\\','|','/','=']:
sys.stdout.write("\r")
sys.stdout.write(r'%s%s%s %s%% ' % (b,int(i/100*100)*'=',a,int(i/100*100)))
sys.stdout.flush()
time.sleep(0.3)
python--第六天练习题
猜你喜欢
转载自www.cnblogs.com/fan-gx/p/11512020.html
今日推荐
周排行