V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
hupantingxue
V2EX  ›  Python

python advance program

  •  
  •   hupantingxue · 2014-03-19 11:13:37 +08:00 · 3944 次点击
    这是一个创建于 3684 天前的主题,其中的信息可能已经有所发展或是发生改变。
    汇总了一些python高阶编程的范例,比如list comprehension, generator, Decorators, map, reduce, Higher-order function...大家一起学习学习:
    https://github.com/hupantingxue/advancedpython
    11 条回复    2014-07-16 12:17:24 +08:00
    Froshal
        1
    Froshal  
       2014-03-19 11:17:03 +08:00
    谢谢分享
    a2z
        2
    a2z  
       2014-03-19 11:25:53 +08:00   ❤️ 1
    感谢分享
    raquelken
        3
    raquelken  
       2014-03-19 11:30:38 +08:00
    分享是好事,但是希望能写正确。。。
    cocorosiekz
        4
    cocorosiekz  
       2014-03-19 11:35:15 +08:00   ❤️ 1
    python官网有how to系列,其中有函数式编程部分,地址http://docs.python.org/2/howto/functional.html
    hupantingxue
        5
    hupantingxue  
    OP
       2014-03-19 13:19:32 +08:00
    @raquelken 有问题可以直接给我提issue,谢谢!
    ljcarsenal
        6
    ljcarsenal  
       2014-03-19 14:41:59 +08:00 via Android
    马克
    yakczh
        7
    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
        8
    polythene  
       2014-03-19 15:51:21 +08:00
    @yakczh try: print(" {0}:{1} ".format(*tu))
    yakczh
        9
    yakczh  
       2014-03-19 16:07:26 +08:00
    @polythene 文档中没看到这种用法,能解释下吗?
    lsj5031
        10
    lsj5031  
       2014-03-19 16:40:09 +08:00
    @yakczh
    unpack the tuple/sequence/collection into positional arguments.
    因为format要跟的参数不是这个tuple,而是你那两个string。
    hupantingxue
        11
    hupantingxue  
    OP
       2014-07-16 12:17:24 +08:00
    更新了一下
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5675 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 06:19 · PVG 14:19 · LAX 23:19 · JFK 02:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.