用户输入一个网址,并对输入的网址进行处理和检测,先对输入的网址去除两边的空白内容,之后再检测网址是否以www 开头,如若不是,则提示用户必须以 www 开头,最后检测是否以 com 结尾,如果不是,则提醒用户必须以 com 结尾。
s=input()
s=s.strip()
if not s.startwith('www'):
print('必须以www开头')
elif not s.endwith('com'):
print('必须以com结尾')
s=input()
s=s.strip()
if not s.startswith('www'):
print('必须以www开头')
if not s.endswith('com'):
print('必须以com结尾')