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

如何通过字符串名称得到类字段

  •  
  •   aoscici · Jun 30, 2020 · 2145 views
    This topic created in 2180 days ago, the information mentioned may be changed or developed.

    比如 peewee 中 query:

    Person.select().where(Person.age == 20).order_by(Person.age.desc())
    

    比如 url 传入的 ?age=20&sort=age_desc, 怎样通过 'age' 凑出 Person.age 来?

    1 replies    2020-06-30 23:27:37 +08:00
    ClericPy
        1
    ClericPy  
       Jun 30, 2020
    这种属性操作参考内置函数 getattr
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1025 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 18:11 · PVG 02:11 · LAX 11:11 · JFK 14:11
    ♥ Do have faith in what you're doing.