Re: [問題] 輸出時用[]取代{} ?

看板Mathematica作者 (養花種魚數月亮賞星星)時間9年前 (2014/11/26 23:31), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《jumbajuice (jumba)》之銘言: : Mathematica是用大括號{}來包住list或array,能不能改成用方括號[] 呢? : 我知道大多文字編緝都有"Replace All"的功能, : 但想知道能不能直接用Mathematica處理。謝謝! : 範例: : 有一個array想要輸出成.txt檔, 指令如下: : myTable = Table[{i, i^2}, {i, 1, 3}]; : Export["test.txt", myTable] : 輸出的檔案會是如下: : {1, 1} : {2, 4} : {3, 9} : 希望是: : [1, 1], : [2, 4], : [3, 9] myTable=Table[{i,i^2},{i,1,10}]; data="["<>ToString@#[[1]]<>","<>ToString@#[[2]]<>"],"&/@myTable; Export["test.txt",data] FilePrint["test.txt"] -- 養花種魚數月亮賞星星 http://chungyuandye.twbbs.org -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.172.114.208 ※ 文章網址: http://www.ptt.cc/bbs/Mathematica/M.1417015909.A.E36.html

11/27 02:22, , 1F
謝謝!
11/27 02:22, 1F
文章代碼(AID): #1KTV9bus (Mathematica)
文章代碼(AID): #1KTV9bus (Mathematica)