假设我有一个带有以下键值对的.ini文件
[keys]
a:"apple"
b:"banana"
o:"orange"
如何在脚本中将这些键值对读入对象(关联数组)?
答案 0 :(得分:3)
这对你有用。
A:=Object() ;Create Array/Object
Loop, read, listing.txt ;loop through file
{
IfInString, A_LoopReadLine, [keys] ;if line has [keys] in it continue
{
continue
}
;fill array with line split on :
A[StrSplit(A_LoopReadLine, "`:").1] :=StrSplit(A_LoopReadLine, "`:").2
}
;print key , value for A
For key, value in A
MsgBox %key% = %value%