想建立如下映射关系:
1 2 3 4 5 6 |
|
在C中我们可以很轻松的用加法实现, 但是换到python, 我想到了以下方法:
1 2 3 4 |
|
看起来一点都不cool, 主要是求字符的后两位字符那里处理的不好, 大伙有没有更pythonic点的方法呢?
ringa_lee2017-04-17 13:05:37
I don’t know why you still need to use chr and ord?? What I mean is: your requirement is very simple. You already know the 26 letters, but you are wrong by 2 digits.
1 2 3 4 5 |
|
The requirement has been fulfilled. I think the key to your question may not be what I answered.
ringa_lee2017-04-17 13:05:37
1 2 3 4 5 6 7 8 9 |
|
Python Challenge Level 1 Walkthrough
ringa_lee2017-04-17 13:05:37
dict(zip(al, map(lambda x : chr((ord(x) - 95) % 26 + 97), al)) )
Sit back and wait for the master...
迷茫2017-04-17 13:05:37
1 2 3 4 5 |
|
Haha, there is no inspection part
巴扎黑2017-04-17 13:05:37
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Not Pythonic at all :(