Error handling Python错误NameError:name'__表名';没有定义

Error handling Python错误NameError:name'__表名';没有定义,error-handling,Error Handling,我是Python新手,我需要你的帮助。我有一台Mac电脑,使用Python 3。使用SublimiteText,这是我在运行代码时收到的信息==>我收到了此错误:NameError:name'\uuuu tablename\uuuuu'未定义 提前谢谢你 我的全部代码是: from flask_sqlalchemy import SQLAlchemy from sqlalchemy import create_engine engine = create_engine('sqli

我是Python新手,我需要你的帮助。我有一台Mac电脑,使用Python 3。使用SublimiteText,这是我在运行代码时收到的信息==>我收到了此错误:
NameError:name'\uuuu tablename\uuuuu'未定义

提前谢谢你

我的全部代码是:

from flask_sqlalchemy import SQLAlchemy
    from sqlalchemy import create_engine
    engine = create_engine('sqlite:///:memory:', echo=True)


from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()



#creare de tabela

from sqlalchemy import Column, Integer, String
class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    name = Column(String)
    fullname = Column(String)
    program = Column(String)
    aka = Column(String)
    adresa = Column(String)
    city = Column(String)
    state = Column(String)
    country = Column(String)
    postalcode = Column(String)

def __repr__(self):
    return "<User(name='%s', fullname='%s', program='%s', aka='%s',adresa='%s',city='%s',country='%s',postalcode='%s',)>" %(
        self.name, self.fullname, self.program, self.aka, self.adresa, self.city, self.state, self.country,self.postalcode)

#creare de tabela
User.__tablename__
table('users', MetaData(bind=None),
    Column('id', Integer(),table=(users), primary_key=True, nullable=False),
    Column('name', String(), table=(users)),
    Column('fullname', String(), table=(users)),
    Column('program', String(), table=(users)),
    Column('aka', String(), table=(users)),
    Column('adresa', String(), table=(users)),
    Column('city', String(), table=(users)), 
    Column('state', String(), table=(user)),
    Column('country', String(), table=(users)),
    Column('postalcode', String(), table=(users), schema=None))
从flask\u sqlalchemy导入sqlalchemy
从sqlalchemy导入创建引擎
engine=create_engine('sqlite://:memory:',echo=True)
从sqlalchemy.ext.declarative导入声明性基础
Base=声明性_Base()
#泰贝拉酒店
从sqlalchemy导入列,整数,字符串
类用户(基本):
__tablename_uu='users'
id=列(整数,主键=True)
名称=列(字符串)
fullname=列(字符串)
程序=列(字符串)
aka=列(字符串)
adresa=列(字符串)
城市=列(字符串)
状态=列(字符串)
国家=列(字符串)
postalcode=列(字符串)
定义报告(自我):
返回“”%(
self.name、self.fullname、self.program、self.aka、self.adresa、self.city、self.state、self.country、self.postalcode)
#泰贝拉酒店
用户。\u\u表名__
表('users',元数据(bind=None),
列('id',Integer(),table=(用户),primary_key=True,nullable=False),
列('name',String(),表=(用户)),
列('fullname',String(),表=(用户)),
列('程序',字符串(),表=(用户)),
列('aka',String(),表=(用户)),
列('adresa',字符串(),表=(用户)),
列('city',String(),表=(用户)),
列('state',String(),table=(user)),
列('country',String(),表=(用户)),
列('postalcode',String(),table=(用户),schema=None))
因为它是一个

[…]格式为
\uuuu spam
的任何标识符(至少两个前导下划线,最多一个尾随下划线)以文本形式替换为
\u classname\uuuuu spam
,其中classname是带前导下划线的当前类名

在您的用例中,您可以使用
User来访问它。\u User\u tablename\u

要避免此问题,请使用一个前导下划线标记varbaile,并删除两个尾随下划线。这是由以下方面提出的:

\u单个\u前导\u下划线
:弱“内部使用”指示器。例如,从M import*不导入名称以下划线开头的对象


谢谢蒂姆!我根据您的帖子更改了代码,但收到了相同的错误。错误是否来自于行
用户。\uu tablename\uu