日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

python將字符串list寫入excel和txt的實例

系統 2212 0

docs = [‘icassp improved human face identification using frequency domain representation facial asymmetry', ‘pattern recognition unsupervised methods classification hyperspectral images low spatial resolution', ‘iscas post layout watermarking method ip protection', ‘computers mathematics applications tauberian theorems product method borel cesàro summability', ‘ieee t. geoscience remote sensing mirs all-weather 1dvar satellite data assimilation retrieval system']

將docs寫入excel

            
docs = [doc.encode('latin-1', 'ignore') for doc in docs]
# convert list to array
docs_array = np.array(docs)
print(type(docs_array))
# saving...
np.savetxt('/Users/Desktop/portrait/jour_paper_docs.csv', docs_array, fmt='%s', delimiter=',')
print('Finish saving csv file')
          

結果

python將字符串list寫入excel和txt的實例_第1張圖片

將docs寫入txt

            
def save(filename, docs):
 fh = open(filename, 'w', encoding='utf-8')
 for doc in docs:
  fh.write(doc)
  fh.write('\n')
 fh.close()
save('/Users/Desktop/portrait/jour_paper_docs.txt', docs)
          

結果

python將字符串list寫入excel和txt的實例_第2張圖片

以上這篇python將字符串list寫入excel和txt的實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。?!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 阿尔山市| 连城县| 曲水县| 康乐县| 临汾市| 喀喇沁旗| 文水县| 沛县| 厦门市| 鱼台县| 三门峡市| 贞丰县| 丹江口市| 武安市| 福清市| 彝良县| 浠水县| 平江县| 临城县| 嘉兴市| 辰溪县| 克东县| 营口市| 开鲁县| 大安市| 嵩明县| 西充县| 萍乡市| 英超| 孝昌县| 怀宁县| 蒙自县| 阳江市| 平安县| 棋牌| 镇雄县| 四川省| 滨海县| 集贤县| 阿尔山市| 大厂|