定义函数
二级标题
- 事情1
- 事情2
- 事情3
代码
#coding:utf-8
# 引入os模块
importos
# 引入时间模块
importtime
importsys
# importlib.reload(sys)
# print (sys.getdefaultencoding( ))
# sys.setdefaultencoding( "utf-8" )
hosts=["192.168.31.1","www.163.com","www.baidu.com","www.taobao.com"]
defpingWebsite(websites):
forwebsiteinwebsites:
start=time.time()
response=os.system("ping -c 1 "+website)
duration=time.time()-start
print("我们正在ping:", website,"耗时:",ms(duration),'\n')
# def printChn(msg):
# return msg.encode(sys.getdefaultencoding(), 'replace')
#中文乱码转译
# def printChn(str):
# chn = str
# #.encode('utf-8').decode('gbk','ignore')
# return chn
defms(a):
returnstr(round(a*1000,1))+" 毫秒"
print('\n')
pingWebsite(hosts)
网友评论