如下代码是以偏移量为13展开计算的。123
源代码如下:
sr1="abcdefghijklmnopqrstuvwxyz"sr2=sr1.upper()
sr=sr1+sr1+sr2+sr2
st="The Zen of Python"sResult=""for j in st:if j==" ":
sResult = sResult +" "
continue
i=sr.find(j)if(i>-1):
sResult=sResult+sr[i+13]print sResult12345678910111213
运行结果为:
Gur Mra bs Clguba
s = raw_input('[开始加密]please input your str:')s = list(s)
n = 0
for sw in s:
s[n] = chr(ord(sw)+3)
n = n + 1
sout = ''
for sw2 in s:
sout = sout + sw2
print '[加密结果]:',sout
解密的类似,主要用到ord、chr函数。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)