简易练习-4 ping网址

如题:

import oshostname = str(input('请输入要测试的网域: '))#将输出结果存放到当前目录的response.txt并在后面cat出#ping -count 传送封包4次response = os.system("ping -c 4 %s" %(hostname)+ "> response.txt") #这里如果有回应response将会呈现为状态0if response == 0:    print(hostname, 'is working!')    os.system("cat response.txt")else:    print(hostname, 'is down!')

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章