📌 📄 内容摘要:
touchsky 在 python语法好难啊 中发帖
最近学python,看老师写的代码看呆了
def countdown(k):
if k > 0:
yield k
yield from countdown(k - 1)
else:
yield 'Blast off'
def prefixes(s):
if s:
yield from prefixes(s[:-1])
yield s
def substrings(s):
if s:
yield from prefixes(s)
yield from substrings(s[1:])
In [2]: (list(countdown(5)),list(prefixes('both')),list(substrings('tops')))
O...
────────── 链接信息 ────────── 🔗 论坛链接: linux.do 📎 访问地址: https://linux.do/t/topic/382295/1 ─────────────────────────────
📢 来源:LINUX DO