【发布时间】:2016-05-11 22:30:52
【问题描述】:
TEXT_TO_READ = """{
"tts_type": "text",
"tts_input": "I am Hungry"
}"""
我的旧代码:
scriptPath = os.path.abspath(__file__)
scriptPath = os.path.dirname(scriptPath)
line = os.path.join(scriptPath, "input.txt")
TEXT_TO_READ["tts_input"] = line
我正在尝试访问 TEXT_TO_READ 的 tts_input。但我想,我犯了一个错误。有人可以帮我吗,如何访问这个?
我无法阅读我的代码的第 4 行并得到错误:TEXT_TO_READ[tts_input] = line AttributeError:“str”对象没有属性“tts_input”。有人可以帮我吗?
【问题讨论】:
-
您的代码不会生成该错误消息。
-
请将原代码放回原处,这样答案的上下文就可以理解了。如果您想展示如何修改代码并提出后续问题,请将其附加到问题而不是替换。
标签: python arrays python-2.7 object