相关疑难解决方法(0)

短rot13函数 - Python

我在Python中搜索一个简短而酷的rot13函数;-)我写了这个函数:

def rot13(s):
    chars = "abcdefghijklmnopqrstuvwxyz"
    trans = chars[13:]+chars[:13]
    rot_char = lambda c: trans[chars.find(c)] if chars.find(c)>-1 else c
    return ''.join( rot_char(c) for c in s ) 
Run Code Online (Sandbox Code Playgroud)

谁能让它变得更好?例如,支持大写字符.

python string encoding

59
推荐指数
8
解决办法
9万
查看次数

标签 统计

encoding ×1

python ×1

string ×1