栏目分类:
子分类:
返回
文库吧用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
文库吧 > IT > 面试经验 > 面试问答

Python函数测试ping

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python函数测试ping

看起来您想要

return
关键字

def check_ping():    hostname = "taylor"    response = os.system("ping -c 1 " + hostname)    # and then check the response...    if response == 0:        pingstatus = "Network Active"    else:        pingstatus = "Network Error"    return pingstatus

您需要使用类似以下内容的变量来捕获/“接收”函数的返回值(pingstatus):

pingstatus = check_ping()

注意:

ping -c
适用于Linux,适用于Windows
ping -n

有关python函数的一些信息:

http://www.tutorialspoint.com/python/python_functions.htm

http://www.learnpython.org/en/Functions

可能需要对Python进行一个很好的入门教程,该教程将涵盖所有基础知识。我建议调查Udacity.com和preacademy.com



转载请注明:文章转载自 www.wk8.com.cn
本文地址:https://www.wk8.com.cn/it/640230.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 wk8.com.cn

ICP备案号:晋ICP备2021003244-6号