一行代码可以做什么?

可以试试 Python 的 from stackoverflow import … 一个脑洞大开的项目, 会自动导入 Stack Overflow 上该关键字的高票回答里能跑起来的代码,而且通常情况下真的是可用的。

>>> from stackoverflow import quick_sort, split_into_chunks
>>> print(quick_sort.sort([1, 3, 2, 5, 4]))
[1, 2, 3, 4, 5]
>>> print(list(split_into_chunks.chunk("very good chunk func")))
['very ', 'good ', 'chunk', ' func']
>>> print("I wonder who made this", split_into_chunks.__author__)
I wonder who made this https://stackoverflow.com/a/35107113
>>> print("but what's the license?", quick_sort.__license__)
but what's the license? CC BY-SA 3.0
>>> assert("nice, attribution!")

https://github.com/drathier/stack-overflow-import

猜你喜欢

转载自blog.csdn.net/saltish1/article/details/88871632
今日推荐