用python 输入一个字符串(内容为网站网址文本)使用正则表达式验证其是否为有效的网址。 1# http|https|ftp|ftps开头 2#.com|.cn结尾
import re finded = re.search('^(https?|ftps?)://([a-z0-9_-]+\.)+(com|cn)$', 'https://www.baidu.com') print('True' if finded != None else 'False')