Python3

Python re demo

2019-07-17  本文已影响0人  JaedenKil

Verify whether user has inputted valid username and qq number.
Require:

import re


def main():
    username = input("Input username")
    qq = input("Input qq number")

    m1 = re.match(r'^[a-zA-Z1-9_]{6,20}$', username)
    m2 = re.match(r'^[1-9]\d{4,11}$', qq)
    if not m1:
        print("Invalid username")
    if not m2:
        print("Invalid qq number")
    if m1 and m2:
        print("Valid username and qq number")


if __name__ == "__main__":
    main()
上一篇下一篇

猜你喜欢

热点阅读