我是 python 新手,但它适用于不同的语言。
#!/usr/bin/python
import sys
import netaddr
print(sys.argv[1])
cidrs = netaddr.iprange_to_cidrs(sys.argv[1])
print cidrs
输出:
./script.py \"223.252.0.0\",\"223.252.127.255\"
"223.252.0.0","223.252.127.255"
Traceback (most recent call last):
File "./script.py", line 7, in <module>
cidrs = netaddr.iprange_to_cidrs(sys.argv[1])
TypeError: iprange_to_cidrs() takes exactly 2 arguments (1 given)