python身份证掩码
时间: 2023-11-11 15:01:21 浏览: 210
Python简单实现子网掩码转换的方法
您好,可以使用正则表达式来实现身份证号码的掩码。以下是示例代码:
```python
import re
def mask_id_number(id_number):
return re.sub(r'(\d{4})\d{10}(\w{4})', r'\1****\2', id_number)
id_number = '110101199001011234'
masked_id_number = mask_id_number(id_number)
print(masked_id_number) # 输出:1101****1234
```
阅读全文