Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
刚刚在 Python 代码中找到了以下模块导入:
from sqlalchemy.ext.declarative import declarative_base,\ AbstractConcreteBase
我很好奇\第一行末尾的反斜杠。它的目的是什么?会不会和下面的一样?
\
from sqlalchemy.ext.declarative import declarative_base, AbstractConcreteBase
是的,它完全一样,这就是反斜杠的重点——它避开了换行符,允许将这条长线分成两半。另一种方法是使用括号:
from sqlalchemy.ext.declarative import (declarative_base, AbstractConcreteBase)
虽然这是一个语法错误: