weidagang2046的專欄

          物格而后知致
          隨筆 - 8, 文章 - 409, 評論 - 101, 引用 - 0
          數據加載中……

          怎樣把一個二維數組寫入文件

          發信人: ilovecpp (cpp), 信區: Python
          標  題: Re: 怎樣把一個二維數組寫入文件?
          發信站: 水木社區 (Tue Jan 17 23:39:50 2006), 站內

          【 在 petre (petre) 的大作中提到: 】
          : 比如
          : A=[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]
          : 寫入文件后文件內容是
          : 1 2 3 4
          : 5 6 7 8
          : 9 10 11 12
          : 13 14 15 16
          : 就是不能帶"[ ]"
          : 每行占一行
          : 急著用,不熟悉python
          : //bow

          print >>open('a.txt', 'w'), '\n'.join([' '.join(map(str, i)) for i in A])

          posted on 2006-01-19 15:48 weidagang2046 閱讀(4878) 評論(1)  編輯  收藏 所屬分類: Python

          評論

          # re: 怎樣把一個二維數組寫入文件  回復  更多評論   

          map(...)
          map(function, sequence[, sequence, ...]) -> list

          Return a list of the results of applying the function to the items of
          the argument sequence(s). If more than one sequence is given, the
          function is called with an argument list consisting of the corresponding
          item of each sequence, substituting None for missing values when not all
          sequences have the same length. If the function is None, return a list of
          the items of the sequence (or a list of tuples if more than one sequence).
          2006-01-19 15:49 | weidagang2046

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 高清| 工布江达县| 密云县| 肇东市| 武鸣县| 岱山县| 涿鹿县| 永福县| 静安区| 平遥县| 邹平县| 酒泉市| 丰台区| 大埔区| 河北省| 汽车| 历史| 洛南县| 武冈市| 巫溪县| 南部县| 开远市| 伊通| 铜梁县| 沛县| 桃园市| 日土县| 泌阳县| 栾城县| 兖州市| 西丰县| 林芝县| 长丰县| 道孚县| 肃宁县| 克什克腾旗| 呈贡县| 马关县| 米脂县| 贵德县| 鄂温|