python advance program

2014-03-19 11:13:37 +08:00
 hupantingxue
汇总了一些python高阶编程的范例,比如list comprehension, generator, Decorators, map, reduce, Higher-order function...大家一起学习学习:
https://github.com/hupantingxue/advancedpython
3960 次点击
所在节点    Python
11 条回复
Froshal
2014-03-19 11:17:03 +08:00
谢谢分享
a2z
2014-03-19 11:25:53 +08:00
感谢分享
raquelken
2014-03-19 11:30:38 +08:00
分享是好事,但是希望能写正确。。。
cocorosiekz
2014-03-19 11:35:15 +08:00
python官网有how to系列,其中有函数式编程部分,地址http://docs.python.org/2/howto/functional.html
hupantingxue
2014-03-19 13:19:32 +08:00
@raquelken 有问题可以直接给我提issue,谢谢!
ljcarsenal
2014-03-19 14:41:59 +08:00
马克
yakczh
2014-03-19 15:35:56 +08:00
问个低阶的问题
怎么用format格式化tuple的子项
比如
tu=('Server', 'Apache/2.2.4 ')

print(" {0}:{1} ".format(tu))
想输出 Server : Apache/2.2.4
但是提示tuple index out of range
polythene
2014-03-19 15:51:21 +08:00
@yakczh try: print(" {0}:{1} ".format(*tu))
yakczh
2014-03-19 16:07:26 +08:00
@polythene 文档中没看到这种用法,能解释下吗?
lsj5031
2014-03-19 16:40:09 +08:00
@yakczh
unpack the tuple/sequence/collection into positional arguments.
因为format要跟的参数不是这个tuple,而是你那两个string。
hupantingxue
2014-07-16 12:17:24 +08:00
更新了一下

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/104960

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX