美文网首页
笔记 2017-08-13

笔记 2017-08-13

作者: 宿liodie | 来源:发表于2017-08-13 20:28 被阅读0次

定义函数

二级标题

  • 事情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)

相关文章

网友评论

      本文标题:笔记 2017-08-13

      本文链接:https://www.haomeiwen.com/subject/zewerxtx.html