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
daijinming
V2EX  ›  Python

Python 新手求教 参数 **config 怎么解释

  •  1
     
  •   daijinming · 2019-03-05 14:09:08 +08:00 · 2342 次点击
    这是一个创建于 1850 天前的主题,其中的信息可能已经有所发展或是发生改变。

    config = {} conn = mysql.connector.connect(**config)

    **config 怎么解释,是类似 C++中的指针吗

    完整代码地址

    9 条回复    2019-03-07 10:12:54 +08:00
    myyou
        1
    myyou  
       2019-03-05 14:13:18 +08:00
    不是,是字典数据解包
    piqizhu
        2
    piqizhu  
       2019-03-05 14:14:30 +08:00
    不是, 在 python 中,它的名词叫 关键字参数 ,具体你搜索一下
    poplar50
        3
    poplar50  
       2019-03-05 14:17:22 +08:00 via Android
    字典参数,用以接收函数未定义的关键字参数
    daijinming
        4
    daijinming  
    OP
       2019-03-05 14:18:05 +08:00
    @myyou @piqizhu @poplar50 感谢,学习啦
    kiddingU
        5
    kiddingU  
       2019-03-05 14:31:49 +08:00
    字典参数,和 golang ... 类似把
    ljpCN
        6
    ljpCN  
       2019-03-05 14:50:08 +08:00 via Android
    类似 js 解构赋值
    CriseLYJ
        7
    CriseLYJ  
       2019-03-05 15:05:07 +08:00
    **有两种作用,一是打包,二是拆包,以字典的形式接收参数!
    dswill
        8
    dswill  
       2019-03-06 15:12:01 +08:00
    学习了。
    julyclyde
        9
    julyclyde  
       2019-03-07 10:12:54 +08:00
    就是一个 dict
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5304 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 05:58 · PVG 13:58 · LAX 22:58 · JFK 01:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.