看板 Python 關於我們 聯絡資訊
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 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.175.53 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1418385705.A.D8B.html
yauhh: 沒錯。小錯誤是最後一行不是if sFixed else 'b'而是 12/12 22:20
yauhh: else 'a'。 12/12 22:21
yauhh: 要寫成一行就是都用lambda了。 12/12 22:36