# 汉字加密 基本汉字范围0x4E00--0x9FA5 共20902个字
ptxt = input("请输入明文文本:")
for p in ptxt:
if 'a' <= p <= 'z':
print(chr(ord('a') + (ord('p') - ord('a') + 3) % 26), end='')
elif 'A' <= p <= 'Z':
print(chr(ord('A') + (ord('p') - ord('A') + 3) % 26), end='')
elif 0x4E00 <= ord(p) <= 0x9FA5:
print(chr(ord(p) + 3), end='')
else:
print(p, end='')
Python二级练习:汉字加密
最新推荐文章于 2023-03-01 17:19:18 发布