想到一些小方法但是编码方面希望可以详解一下

img

img


输入后可采用split方法获取phonenum和year

img

img

img

希望有人能看到这个帖子并愿意解答🥺

img

稍等

已完成,代码如下:

def judge_psw(psw):
    _dict = {
        1: False,
        2: False,
        3: False,
        4: False
    }
    count = 0
    for char in psw:
        if char.isdigit() and _dict[1] == False:
            _dict[1] = True
            count += 1
        if char.islower() and _dict[2] == False:
            _dict[2] = True
            count += 1
        if char.isupper() and _dict[3] == False:
            _dict[3] = True
            count += 1
        if len(char) > 8:
            _dict[4] = True
            count += 1
    return count


def judge_phone(phonenum, year):
    left = int(str(phonenum)[-1]) * 2 + 5
    y = left * 50 + 1771 - year
    left_result = y % 100
    if left_result == 2021 - int(year):
        print("YES")
        return
    print("NO")
    return


def isOdd(num):
    if num % 2 != 0:
        print("{num} is odd".format(num=num))
        return
    print("{num} is not odd".format(num=num))
    return


def func(m, n):
    temp = 0
    for i in range(1, n+1):
        temp += pow(i, m)
    return temp

print("##############################")
psw = 'Python'
print(judge_psw(psw))
print("##############################")

_input = input("请输入手机号和出生年份,用空格隔开:如")  # 13199886666 2000
phone, year = _input.split(" ")
judge_phone(phone, int(year))
print("##############################")

_num = 3
isOdd(_num)
print("##############################")

s = 0
s = func(1, 100) + func(2, 50) + func(-1, 10)
print("s的值为:", round(s))
print("##############################")


有问题及时沟通