推荐学习书目
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
shawndev
V2EX  ›  Python

请问 aosabook/500lines 中 guido 写的爬虫中,__ini__ 参数中单独的 * 是什么用法?

  •  
  •   shawndev · Oct 15, 2017 · 2774 views
    This topic created in 3158 days ago, the information mentioned may be changed or developed.
    源码地址: https://github.com/aosabook/500lines/blob/master/crawler/code/crawling.py
    第 53 行 loop=None 前面单独的星号是什么用法? google 找不到对应的答案(也可能是我没找对关键字)
    9 replies    2017-10-15 23:41:38 +08:00
    shawndev
        1
    shawndev  
    OP
       Oct 15, 2017
    class Crawler:
    def __init__(self, roots,
    exclude=None, strict=True, # What to crawl.
    max_redirect=10, max_tries=4, # Per-url limits.
    max_tasks=10, *, loop=None):

    代码在这里
    guyskk0x0
        2
    guyskk0x0  
       Oct 15, 2017 via Android
    keyword only parameter
    shawndev
        3
    shawndev  
    OP
       Oct 15, 2017
    @guyskk0x0 那么他和 *args 和 **kwargs 有什么区别呢,怎么从中取值?
    shawndev
        4
    shawndev  
    OP
       Oct 15, 2017
    @guyskk0x0 查到了,PEP3102 万分感谢
    XIVN1987
        5
    XIVN1987  
       Oct 15, 2017 via Android
    @shawndev
    它的意思是后面的参数只能用关键字传参,不能用位置参数传参,,它本身没有值
    shawndev
        6
    shawndev  
    OP
       Oct 15, 2017
    @XIVN1987 感谢,看了下 PEP 好像有点懂了~
    mec
        7
    mec  
       Oct 15, 2017
    python3 新特性这是
    boyxupers
        8
    boyxupers  
       Oct 15, 2017 via iPhone
    3 语法有点太乱了…
    sunwei0325
        9
    sunwei0325  
       Oct 15, 2017
    @boyxupers 我怎么觉得 3 的语法很先进呢..
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5659 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 06:42 · PVG 14:42 · LAX 23:42 · JFK 02:42
    ♥ Do have faith in what you're doing.