Skip to content

Commit

Permalink
拆分为函数,实现ip a功能,让工具更加类似于Linux的ip a命令
Browse files Browse the repository at this point in the history
  • Loading branch information
omaidb committed Jun 19, 2021
1 parent ae7bcbd commit 61301dc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ def showip():
ip = sys.argv[1]
except:
# 如果参数为空,ip参数就为空
ip = None
查看本地公网ip()
view_local_public_network_ip()
ipconfig()

else:
# 如果ip参数为a,就执行
if ip == 'a':
ipconfig()
elif ip[0].isdigit() or ip[1].isalpha():
查询ip归属地(ip)
query_ip_attribution(ip)


def 查看本地公网ip():
def view_local_public_network_ip():
"""
查看本地公网ip
:return:打印json格式的ip信息
Expand All @@ -51,7 +50,7 @@ def 查看本地公网ip():
pprint(response.json())


def 查询ip归属地(ip):
def query_ip_attribution(ip):
"""
查询ip归属地
:param ip:传入ip或域名
Expand Down

0 comments on commit 61301dc

Please sign in to comment.