pickle
とかありましたが、数字が入っているとバグるようなので原始的にやります。
data = [[1,2,3,4,5,6], [1,2,3,4,5,6]]
def c(data):
outputfile = open("./output.txt", "w")
for d in data:
if(len(d) == 6):
str_list = map(str, d)
write_data = ",".join(str_list)+"\n"
outputfile.write(write_data)
outputfile.close()
c(data)
結果
output.txt
1,2,3,4,5,6
1,2,3,4,5,6
Point
- 一度使用したファイルのcloseを忘れずに
- mapで要素全てをStringに変換