用Python2710編寫凱撒密碼加密和解密程序?
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函數。
上一篇python39怎么用
下一篇ppt怎么去掉超鏈接提示
用Python2710編寫凱撒密碼加密和解密程序?
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函數。