比如随机输入一个字符串,比如zdfgh ,输出的是bfhij ,请问怎么弄呢
# 分开打印
s = input('请输入字符串:')
for c in s:
if ord(c) >= 122:
print(chr(ord(c) - 26 + 2))
else:
print(chr(ord(c) + 2))
#一起打印
s = input('请输入字符串:')
s_new = ''
for c in s:
if ord(c) >= 122:
s_new = s_new + chr(ord(c) - 26 + 2)
else:
s_new = s_new + chr(ord(c) + 2)
print(s_new)