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

使用 Python 定义函数时,貌似很少用到可变参数这种形式啊?

  •  
  •   wsds · Aug 24, 2018 · 1041 views
    This topic created in 2848 days ago, the information mentioned may be changed or developed.

    看了一下,都是源码用的多,很少有自己写这种可变参数啊,大家平时用这种吗?

    def test_kwargs(first, *args, **kwargs):
       print 'Required argument: ', first
       for v in args:
          print 'Optional argument (*args): ', v
       for k, v in kwargs.items():
          print 'Optional argument %s (*kwargs): %s' % (k, v)
     
    test_kwargs(1, 2, 3, 4, k1=5, k2=6
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3287 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 11:12 · PVG 19:12 · LAX 04:12 · JFK 07:12
    ♥ Do have faith in what you're doing.