用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - python代码库

身份证1

2022-11-19 作者: 马江南举报

[python]代码库

ID = input('请输入十八位身份证号码: ')
if len(ID) != 18:
    print("错误的身份证号码")
else:
    print("你的身份证号码是 " + ID)

    ID_check = ID[17]
    W = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
    ID_num = [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]
    ID_CHECK = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
    ID_aXw = 0
    for i in range(len(W)):
        ID_aXw = ID_aXw + int(ID[i]) * W[i]

    ID_Check = ID_aXw % 11
    if ID_check != ID_CHECK[ID_Check]:
        print('错误的身份证号码')
    else:
        print('正确的身份证号码')

        ID_add = ID[0:6]
        ID_birth = ID[6:14]
        ID_sex = ID[14:17]

        # ID_add是身份证中的区域代码,如果有一个行政区划代码字典,就可以用获取大致地址#
        class ShoppingCart(object):
            """Creates shopping cart objects
            for users of our fine website."""
            items_in_cart = {}

            def __init__(self, customer_name):
                self.customer_name = customer_name

            def add_item(self, product, price):
                """Add product to the cart."""
                if not product in self.items_in_cart:
                    self.items_in_cart[product] = price
                    print
                    product + " added."
                else:
                    print
                    product + " is already in the cart."

            def remove_item(self, product):
                """Remove product from the cart."""
                if product in self.items_in_cart:
                    del self.items_in_cart[product]
                    print
                    product + " removed."
                else:
                    print
                    product + " is not in the cart."


        my_cart = ShoppingCart("wangweiwei")
        my_cart.add_item("apple", 12)

        year = ID_birth[0:4]
        month = ID_birth[4:6]
        day = ID_birth[6:8]
        print("生日: " + year + '年' + month + '月' + day + '日')

        if int(ID_sex) % 2 == 0:
            print('性别:女')
        else:
            print('性别:男')











网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...