将AppleScript列表转换为字符串
问题描述:
我想知道是否有简短的方法将AppleScript列表转换为分隔每个项目的字符串。我可以用我想要的更长的方式来实现这一点,所以我想知道是否有一种简单的方法来实现这一点。基本上,我想采取一个列表,如{1,2,3}
,并将其转换为字符串"1, 2, 3"
。我可以这样做以下,但所得到的字符串后面会导致一个逗号:将AppleScript列表转换为字符串
set myList to {"1.0", "1.1", "1.2"}
set Final to ""
if (get count of myList) > 1 then
repeat with theItem in myList
set Final to Final & theItem & ", "
end repeat
end if
答
有一个短暂的办法,这就是所谓的text item delimiters
set myList to {"1.0", "1.1", "1.2"}
set saveTID to text item delimiters
set text item delimiters to ", "
set Final to myList as text
set text item delimiters to saveTID