【问题标题】:Applescript saving each item from a list as textApplescript 将列表中的每个项目保存为文本
【发布时间】:2016-08-06 18:37:23
【问题描述】:

我有一个数字列表(数字的数量是随机的)

例如这是我目前的结果:

Result:
{"1024343495", "84734348416", "100434439171", "86343425", "13434290", "83434946", "81711343497", "43534347319", "863434490"}

我想将它们打印到文本文件中,或者保存在剪贴板中,但这不起作用

set the clipboard to myList

所以我尝试将所有内容转换为字符串:

set the clipboard to myList as string

但是我只有一个巨大的数字: 1024343495847343484161004344391718634342513434290834349468171134349743534347319863434490

【问题讨论】:

标签: arrays list applescript


【解决方案1】:

试试

set myString to ""
set i to 0
repeat (number of items in myList) times
    set i to i + 1
    set myString to myString & ((item i of myList)as string) &  ", "-- this last bit here is what goes in between each list item
end repeat
return myString

结果“1024343495、84734348416、100434439171”-等

【讨论】:

    【解决方案2】:

    您可以在相应地设置text item delimiters 后使用您的代码。

    set myList to {"1024343495", "84734348416", "100434439171", "86343425", "13434290", "83434946", "81711343497", "43534347319", "863434490"}
    set {TID, text item delimiters} to {text item delimiters, ", "}
    set the clipboard to myList as text
    set text item delimiters to TID
    

    【讨论】:

      猜你喜欢
      • 2021-04-07
      • 2019-01-24
      • 1970-01-01
      • 1970-01-01
      • 2012-09-24
      • 2022-11-07
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      相关资源
      最近更新 更多