如何将.ini文件中的所有键值对读入对象?

时间:2018-02-20 13:10:57

标签: scripting autohotkey ini

假设我有一个带有以下键值对的.ini文件

[keys]
a:"apple"
b:"banana"
o:"orange"

如何在脚本中将这些键值对读入对象(关联数组)?

1 个答案:

答案 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%
相关问题