property-list - 如何在茄子的属性列表中动态插入键和值
问题描述
我已获取数据作为列表列表(内部列表由 2 个值组成,例如 (name,sam)),现在我想读取每个内部列表的数据并将第一个数据添加为键并将第二个数据添加为值财产清单。例如,((name,sam),(date,fourth),(age,twenty)) = 列表列表
转换为 = (name:"sam",date:"fourth",age:"twenty") = 属性列表
我怎样才能做到这一点?
set excelRead to WorkBook(ResourcePath(fileName))
set readColumns to excelRead.Worksheet(sheetName)
set listOfData to cellRange("A:B") of readColumns
put (:) into newPlist
repeat with each item of listOfData
put item 1 of it into key
put item 2 of it into Value
end repeat
解决方案
您只需在变量名周围加上方括号,即可将其用作属性列表中的键:
put Value into newPlist.(key)
put Value into (key) of newPlist
put Value into newPlist's (key)
它在此处的 SenseTalk 参考中:使用变量引用属性列表键
推荐阅读
- python - 在 python 与 ipython 中加载模块
- android - 如何从 Android 获取 idtoken 并发布到服务器后端 node.js
- c# - C# NetworkcommsDotNet 重置缓冲区
- terraform - 从 Terraform 中的 Vault 读取 GCP 凭据?
- r - 如何使所有类型的犯罪出现在直方图中?
- excel - 在 VBA 中使用“IF”条件的条件格式不起作用?
- python-3.x - 如何在熊猫中并排打印图像?
- r - 当每个数据框中不存在所有这些列时,如何从数据框列表中删除特定列
- ruby-on-rails - has_many 通过和 Cocoon 连接表上的值
- ios - 在获取消息列表firebase时获取重复数据