我正在使用google-cloud-billing-budgets
自动创建预算,但在尝试创建阈值规则时出错。
我的代码看起来像这样
new_thresholde_rule = budgets.ThresholdRule({
'threshold_percent' : [0.9]
})
new_budget_details = budgets.Budget({
'display_name': projectId,
'amount': new_amount,
'threshold_rules': new_thresholde_rule,
})
new_budget = client.create_budget(
request = {
'parent': BILLING_ACCOUNT,
'budget': new_budget_details,
}
)
错误是:
TypeError: [0.9] has type list, but expected one of: int, long, float
我一直在跟踪documentation,但它没有给我任何暗示
最后,我可以解决它。这就是解决方案:
我必须在
'threshold_rules': [new_thresholde_rule]
中使用括号,仅此而已。它起作用了相关问题 更多 >
编程相关推荐