Python HAIL CAESAR (凯撒密码) 2
2015-06-15 22:14
656 查看
def applyCoder(text, coder):
"""
Applies the coder to the text. Returns the encoded text.
text: string
coder: dict with mappings of characters to shifted characters
returns: text after mapping coder chars to original text
"""
### TODO.
new = ""
for word in text:
if word in string.ascii_lowercase or word in string.ascii_uppercase:
new = new + coder[word]
else:
new = new + word
return new
少了红色部分一直返回 keyerror /(ㄒoㄒ)/~~
"""
Applies the coder to the text. Returns the encoded text.
text: string
coder: dict with mappings of characters to shifted characters
returns: text after mapping coder chars to original text
"""
### TODO.
new = ""
for word in text:
if word in string.ascii_lowercase or word in string.ascii_uppercase:
new = new + coder[word]
else:
new = new + word
return new
少了红色部分一直返回 keyerror /(ㄒoㄒ)/~~
相关文章推荐
- virtualenv、fabric 和 pip 是 pythoneer 的三大神器
- numpy解方程
- python读取mnist
- python 练习题
- python模块学习 logging
- Windows下Scrapy安装
- PyCharm简单使用介绍及注意事项
- [Python基础]007.字符串
- python学习之web2py框架
- 安装pip后命令行出错
- python模块学习 hashlib
- Python字符串的encode与decode
- Python MD5加密
- NLPIR(ICTCLAS2015)python调用接口配置
- Python正则表达式教程
- Python之PyAudio使用
- python 学习笔记(一)通过做题来熟悉python 的基本语法
- python import 同名模块
- Python
- python-sphinx 2.6.5的一个bug