V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
lisisi
V2EX  ›  Python

from models import User 和 from orm import models 中的两个 models 会冲突吗?

  •  
  •   lisisi · Apr 12, 2025 · 1863 views
    This topic created in 380 days ago, the information mentioned may be changed or developed.
    from models import User
    from orm import models
    

    这两行引入中,两个 models 会冲突吗?第 2 行这个 models 会覆盖第 1 行的 models 吗?

    3 replies    2025-04-16 09:29:04 +08:00
    wyntalgeer
        1
    wyntalgeer  
       Apr 12, 2025
    不会;不会。
    NoOneNoBody
        2
    NoOneNoBody  
       Apr 12, 2025
    这样看不会

    1. 这两句顺序调换就可能会了
    2. 如果当前目录内有个 models.py 可能有问题

    不建议用 和 module 同名来命名 .py 文件,组织项目文件时就要考虑这点
    frostming
        3
    frostming  
       Apr 16, 2025
    1. 这两句顺序调换就可能会了
    2. 如果当前目录内有个 models.py 可能有问题

    两种都不会
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4417 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 04:11 · PVG 12:11 · LAX 21:11 · JFK 00:11
    ♥ Do have faith in what you're doing.