Re: [问题] 如何能做到字母进位呢?

楼主: johnjohnlin (嗯?)   2014-12-12 20:01:42
def incaz(s):
sFixed = s.rstrip('z')
lz = len(s)-len(sFixed)
return (sFixed[:-1] + chr(ord(sFixed[-1])+1) if sFixed else 'b') + 'a'*lz
试着做了一个三行本体的版本
想不到怎么压到一行 XD
作者: yauhh (小y宝贝)   2014-12-12 22:20:00
没错。小错误是最后一行不是if sFixed else 'b'而是else 'a'。要写成一行就是都用lambda了。

Links booklink

Contact Us: admin [ a t ] ucptt.com