python2.7.5实现ROT13编解码
来源:互联网 发布:java set 取值 编辑:程序博客网 时间:2024/05/23 12:30
#! /usr/bin/python
"""This function need two input:the string and the moving number."""
def rot13(st,t):
n=''
l=len(st)
for i in range(l):
if ord(st[i])>ord('Z'):
if (ord(st[i])+t)>ord('z'):
n=n+chr(ord(st[i])+t-26)
elif (ord(st[i])+t)<ord('a'):
n=n+chr(ord(st[i])+t+26)
else:
n=n+chr(ord(st[i])+t)
elif (ord(st[i])+t)>ord('Z'):
n=n+chr(ord(st[i])+t-26)
elif (ord(st[i])+t)<ord('A'):
n=n+chr(ord(st[i])+t+26)
else:
n=n+chr(ord(st[i])+t)
return n
s=raw_input("input s:")
t=int(raw_input("input t:"))
print rot13(s,t)
"""This function need two input:the string and the moving number."""
def rot13(st,t):
n=''
l=len(st)
for i in range(l):
if ord(st[i])>ord('Z'):
if (ord(st[i])+t)>ord('z'):
n=n+chr(ord(st[i])+t-26)
elif (ord(st[i])+t)<ord('a'):
n=n+chr(ord(st[i])+t+26)
else:
n=n+chr(ord(st[i])+t)
elif (ord(st[i])+t)>ord('Z'):
n=n+chr(ord(st[i])+t-26)
elif (ord(st[i])+t)<ord('A'):
n=n+chr(ord(st[i])+t+26)
else:
n=n+chr(ord(st[i])+t)
return n
s=raw_input("input s:")
t=int(raw_input("input t:"))
print rot13(s,t)
0 0
- python2.7.5实现ROT13编解码
- python2.7 编解码问题
- WCF编解码实现
- 用Python实现ROT13
- 【腾讯TMQ】Python2中的中文字符编解码浅析
- python2.7 中unicode、str的编解码关系
- python2.7 中unicode、str的编解码关系
- Ios实现amr编解码
- BASE64编解码简单实现
- Java实现BASE64编解码
- matlab实现算术编解码
- VB实现Base64 编解码
- Java实现BASE64编解码
- openmax 编解码的实现
- VC实现URL编解码
- Java实现BASE64编解码
- java实现Base64编解码
- PNG编解码实现---LodePNG
- C语言 内存管理详解
- java 内存溢出
- 浏览器加载和渲染html的顺序
- Channel(通道)的简介
- 历届试题 地宫取宝
- python2.7.5实现ROT13编解码
- CSS定义input disabled样式
- OCP 1Z0 051 68
- 给dede栏目添加上缩略图功能
- Boost 库多线程编程一
- Kendo UI-html5 ui开源框架
- 如何获取ios应用的URL Schemes
- ubuntu下tcpdump
- C++的map类