如何将.INI文件中的所有键值对读取到对象中



假设我有一个.ini文件,其中包含以下键值对

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

如何在脚本中读取这些键,值对?

这应该对您有用。

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%

最新更新