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

如何连接变量

  •  
  •   songdg · Sep 27, 2018 · 3047 views
    This topic created in 2924 days ago, the information mentioned may be changed or developed.
    table = data.root.daily.ST123 是读取 pytables 文件中的一页数据,变量 n=125,如果要读取 data.root.daily.ST125 中的数据该如何使用该变量。
    5 replies  •  2018-09-29 09:05:03 +08:00
    zzth370
        1
    zzth370  
       Sep 27, 2018   ❤️ 1
    可以 getattr 试试
    sww4718168
        2
    sww4718168  
       Sep 27, 2018
    ```python
    getattr(data.root.daily, 'ST{n}'.format(n=n))
    ```
    songdg
        3
    songdg  
    OP
       Sep 28, 2018
    @sww4718168 谢谢帮助,还有个问题如果要读取 data.root.daily.ST001,但是不能赋值 n=001。
    ysc3839
        4
    ysc3839  
       Sep 28, 2018 via Android   ❤️ 1
    songdg
        5
    songdg  
    OP
       Sep 29, 2018
    @ysc3839 问题解决,谢谢帮助。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4691 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 08:02 · PVG 16:02 · LAX 01:02 · JFK 04:02
    ♥ Do have faith in what you're doing.