python - 从 .json 文件中获取数据时,“元组”对象没有“格式”属性
问题描述
(使用python 2.7)
mySettings 是一个 .json 文件
我一直在使用 Streamlabs 为 twitch 开发聊天机器人脚本,如果开发人员将设置格式化为 .json 文件中的设置,他们有一个系统允许流媒体编辑设置:
},
"AcceptVipResponse": {
"type": "textbox",
"value": "Congratulations {0} you are now VIP!",
"label": "When a user sucesfully purchases VIP",
"tooltip": "Message sent when the bot succesffully gives them VIP role \r\n {0} = user",
"group": "Responses"
},
这几乎适用于我的所有代码,例如:
Parent.SendStreamMessage(mySettings.AcceptVipResponse.format(data.GetParam(1)))
'Parent.SendStreamMessage' 向流的聊天发送消息,'data.GetParam(1)' 只是聊天者用户名的字符串
但是,当它运行代码行时:
Parent.SendStreamMessage(mySettings.NotEnoughResponse.format(data.UserName,Parent.GetCurrencyName, str(cost)))
我收到一条错误消息:
“元组”对象没有属性“格式”
这所指的 .json 文件的部分是:
},
"NotEnoughResponse": {
"type": "textbox",
"value": "{0} you don't have enough {1} to purchase vip it costs {2}",
"label": "Not enough currency response",
"tooltip": "Message sent when user try to tombola more than they have \r\n {0} = user \r\n {1} = Currency name \r\n {2} = Cost",
"group": "Responses"
},
我不知道为什么 python 将一个称为元组,但其他的完全没问题,任何帮助将不胜感激。
解决方案
推荐阅读
- wso2 - wso2:vault-lookup() 在 Wso2 API 管理器中返回空值
- java - 敏感数据的存储
- apache-flink - Flink 如何决定何时采取检查点?
- python - 带有过滤器的 Pandas 小计到整个组
- rest - POST 请求上传文件中 JWT 自动化阶段的 Quarkus Vertx 超时
- python - 如何在pytorch中重塑图像
- pandas - 覆盖 Pandas 数据框是 NA,基于多列
- pine-script - 如何从版本 2 转换为版本而不会在 pinescript 中出现未清除的 indentiier 错误?
- docker - 无法从 Springboot 应用程序连接 Kafka
- r - 根据条件将多列中的值替换为另一列的值