推荐学习书目
› 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 · 3178 views
    This topic created in 2973 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
    zzth370
    Sep 27, 2018❤️1
    1
    可以 getattr 试试
    sww4718168
    sww4718168
    Sep 27, 2018
    2
    ```python
    getattr(data.root.daily, 'ST{n}'.format(n=n))
    ```
    songdg
    songdg
    OP
    Sep 28, 2018
    3
    @sww4718168 谢谢帮助,还有个问题如果要读取 data.root.daily.ST001,但是不能赋值 n=001。
    ysc3839
    ysc3839
    Sep 28, 2018 via Android❤️1
    4
    songdg
    songdg
    OP
    Sep 29, 2018
    5
    @ysc3839 问题解决,谢谢帮助。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4798 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 02:50 · PVG 10:50 · LAX 18:50 · JFK 21:50
    ♥ Do have faith in what you're doing.