推荐学习书目
› 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 · 3026 views
    This topic created in 3316 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
    shawndev
    OP
    Oct 15, 2017
    1
    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
    guyskk0x0
    Oct 15, 2017 via Android
    2
    keyword only parameter
    shawndev
    shawndev
    OP
    Oct 15, 2017
    3
    @guyskk0x0 那么他和 *args 和 **kwargs 有什么区别呢,怎么从中取值?
    shawndev
    shawndev
    OP
    Oct 15, 2017
    4
    @guyskk0x0 查到了,PEP3102 万分感谢
    XIVN1987
    XIVN1987
    Oct 15, 2017 via Android
    5
    @shawndev
    它的意思是后面的参数只能用关键字传参,不能用位置参数传参,,它本身没有值
    shawndev
    shawndev
    OP
    Oct 15, 2017
    6
    @XIVN1987 感谢,看了下 PEP 好像有点懂了~
    mec
    mec
    Oct 15, 2017
    7
    python3 新特性这是
    boyxupers
    boyxupers
    Oct 15, 2017 via iPhone
    8
    3 语法有点太乱了…
    sunwei0325
    sunwei0325
    Oct 15, 2017
    9
    @boyxupers 我怎么觉得 3 的语法很先进呢..
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   906 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 21:17 · PVG 05:17 · LAX 13:17 · JFK 16:17
    ♥ Do have faith in what you're doing.