Следующий код:
import sys
if __name__ == "__main__":
# print the given IP to the script
ip = sys.argv[1]
print(ip)
# your condition
if len(ip) == 13:
print("IP address format is correct")
else:
print("wrong IP format")
exit()
сохранен как скрипт test.py
вместе с вызовом скрипта как:
python3 test.py 255.255.255.0
или в Python 2.X
python test.py 255.255.255.0
будет делать больше, чем вы хотите, для примера ввода IP: 255.255.255.0