import sys import re #Make sure we have a single URL argument. if len(sys.argv) != 2: print (sys.stderr, "URL Required") sys.exit(-1) #Easie access. url = sys.argv[1] #Ensure we were passed a somewhat valid URL. #This is a superficial test. if re.match(r'^https?:/{2}\w.+$', url): print("This looks valid.") else: print("This looks invalid.")
终于进入到正则表达式的学习了。
PyCharm真是个不错的IDE呢,免费版于我暂时够用罗~~
re.match(r'^https?:/{2}\w.+$', url)