Python中将array类型不按科学计数法存在文件中的方法
生活随笔
收集整理的這篇文章主要介紹了
Python中将array类型不按科学计数法存在文件中的方法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
直接上代碼:
from numpy import *import numpy as np
Drug_array = zeros((708,708),dtype = int)
f = open('D:\mat_drug_drug.txt')
lines = f.readlines()
Drug_row = 0
for line in lines:
list = line.strip('\n').split(' ')
Drug_array[Drug_row:] = list[:]
Drug_row += 1
print(shape(Drug_array))
np.savetxt('D:\開始吧,少年\數(shù)據(jù)提取\最終提取\drug_drug.txt',Drug_array,fmt = ['%s']*Drug_array.shape[1],newline = '\n')
直接存TXT中總是科學(xué)計(jì)數(shù)法表示的,想直接看數(shù)字不是很方便,用fmt可以是實(shí)現(xiàn)不用科學(xué)計(jì)數(shù)法存儲。
fmt詳細(xì)內(nèi)容:https://docs.scipy.org/doc/numpy/reference/generated/numpy.savetxt.html
轉(zhuǎn)載于:https://www.cnblogs.com/monkeyT/p/9301082.html
總結(jié)
以上是生活随笔為你收集整理的Python中将array类型不按科学计数法存在文件中的方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html星空代码在线,怎么操作html星
- 下一篇: [Python] 制作启动uiautom