跳到主要内容

Set

通过索引设置数组值。

请注意,对于 .docbuilder 文件,不使用 CDocBuilderValue.Set 方法。

语法

def Set(self, key: int, value: CDocBuilderValue) -> None

参数

名称类型描述
keyint数组值的索引。
valueCDocBuilderValue要设置的数组值。

示例

builder = docbuilder.CDocBuilder()
context = builder.GetContext()
globalObj = context.GetGlobal()
api = globalObj["Api"]
document = api.Call("GetDocument")
charts = document.Call("GetAllCharts")
chart = api.Call("CreateChart", "bar3D", [[200, 240, 280], [250, 260, 280]],
["Projected Revenue", "Estimated Costs"], [2014, 2015, 2016],
4051300, 2347595, 24)
charts.Set(1, chart)

索引运算符

operator[] 后缀表达式也可用于通过索引设置数组值:

array[index] = value