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

python 如何生成如下的注释?

  •  
  •   billgreen1 · 2016-02-24 16:20:57 +08:00 · 3623 次点击
    这是一个创建于 2955 天前的主题,其中的信息可能已经有所发展或是发生改变。

    很多 python 的库,其文档的注释里面都包含使用案例, 比如:

    """
    Helper class to unstack data / pivot with multi-level index
    
    Parameters
    ----------
    level : int or str, default last level
        Level to "unstack". Accepts a name for the level.
    
    Examples
    --------
    >>> import pandas as pd
    >>> index = pd.MultiIndex.from_tuples([('one', 'a'), ('one', 'b'),
    ...                                    ('two', 'a'), ('two', 'b')])
    >>> s = pd.Series(np.arange(1.0, 5.0), index=index)
    >>> s
    one  a   1
         b   2
    two  a   3
         b   4
    dtype: float64
    
    >>> s.unstack(level=-1)
         a   b
    one  1  2
    two  3  4
    
    >>> s.unstack(level=0)
       one  two
    a  1   2
    b  3   4
    
    Returns
    -------
    unstacked : DataFrame
    """
    

    我想这些应该不是手动敲上去的,应该是通过某种途径自动生成的
    是如何做到的?

    12 条回复    2016-02-25 10:46:20 +08:00
    GPU
        1
    GPU  
       2016-02-24 16:25:31 +08:00
    手动打的。
    knightdf
        2
    knightdf  
       2016-02-24 16:30:40 +08:00
    手打的吧。。。
    flyee
        3
    flyee  
       2016-02-24 16:32:43 +08:00   ❤️ 1
    手打 doctest
    nailuoGG
        4
    nailuoGG  
       2016-02-24 17:35:49 +08:00
    可以复制 Python 解释器下的文本输出。当然你硬是要手打的话,也行。
    glasslion
        5
    glasslion  
       2016-02-24 17:41:11 +08:00
    真的是手打的
    wizardoz
        6
    wizardoz  
       2016-02-24 17:44:55 +08:00
    确实不是手动打的。
    应该是复制粘贴……
    BruceYuan
        7
    BruceYuan  
       2016-02-24 18:13:35 +08:00
    哈哈,我也觉得是手打的
    marshalshi
        8
    marshalshi  
       2016-02-24 18:19:04 +08:00
    这个是某种规范的注释结构,手打的。
    gamexg
        9
    gamexg  
       2016-02-24 18:32:15 +08:00
    手动打的,是一种简易单元测试。
    WangYanjie
        10
    WangYanjie  
       2016-02-24 18:40:17 +08:00
    主要靠十根手指
    bbking
        11
    bbking  
       2016-02-24 21:24:35 +08:00
    感觉是 IDLE 先输入命令,然后 copy 过来的
    julyclyde
        12
    julyclyde  
       2016-02-25 10:46:20 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5877 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 02:02 · PVG 10:02 · LAX 19:02 · JFK 22:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.