首先來個簡單的例子,利用Python實(shí)現(xiàn)匹配163郵箱的代碼:
#-*- coding:utf-8 -*-__author__ = '楊鑫'import retext = input("Please input your Email address:/n"):if re.match(r'[0-9a-zA-Z_]{0,19}@163.com',text): print('Email address is Right!')else: print('Please reset your right Email address!')
接著來一個匹配所有郵箱格式的代碼:
#-*- coding:utf-8 -*-__author__ = '楊鑫'import retext = input("Please input your Email address:/n")if re.match(r'^[0-9a-zA-Z_]{0,19}@[0-9a-zA-Z]{1,13}/.[com,cn,net]{1,3}$',text):#if re.match(r'[0-9a-zA-Z_]{0,19}@163.com',text): print('Email address is Right!')else: print('Please reset your right Email address!')
以上這篇Python實(shí)現(xiàn)正則表達(dá)式匹配任意的郵箱方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持VEVB武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選