在Python中不断获取此“属性错误”

时间:2018-10-08 05:10:00

标签: python class attributes

谁能解释为什么这种情况一直在我身上发生?

model = model.load("lstm_model.h5")

我收到一条错误消息:

  

打印(TourAgency.tours)

     

AttributeError:类型对象'TourAgency'没有属性'tours'

1 个答案:

答案 0 :(得分:0)

您的班级没有 tours 属性,而只有 _tours 属性。也许您想改用它。

请记住,在Python中,如果属性名称以下划线开头,则意味着该属性应为 private ,而不应供 user 使用。

我希望这可以对您有所帮助!干杯!