当前位置:网站首页>Python saves the list data
Python saves the list data
2020-11-06 01:27:00 【Elementary school students in IT field】
For a list a[]:
preservation
filename = open(‘a.txt’, ‘w’)
for value in a:
filename.write(str(value))
filename.close()
Read
f= open(“a.txt”,“r”)
a = f.read()
f.close()
Although this method takes up less space , But the original list Format will be broken . You can also use the following method for this purpose , This method can keep list Original format .
preservation
import numpy as np
a=np.array(a)
np.save(‘a.npy’,a) # Save as .npy Format
Read
a=np.load(‘a.npy’)
a=a.tolist()
ps:
If it reads .txt The document is in Chinese , You need to add the following :
readme = pd.read_csv(‘ Read me .txt’,sep=’:’,encoding=“utf-8”, engine=‘python’,header=None)
readme = np.array(readme)
版权声明
本文为[Elementary school students in IT field]所创,转载请带上原文链接,感谢
边栏推荐
- Arrangement of basic knowledge points
- Aprelu: cross border application, adaptive relu | IEEE tie 2020 for machine fault detection
- 一篇文章教会你使用HTML5 SVG 标签
- 深度揭祕垃圾回收底層,這次讓你徹底弄懂她
- React design pattern: in depth understanding of react & Redux principle
- Summary of common string algorithms
- 关于Kubernetes 与 OAM 构建统一、标准化的应用管理平台知识!(附网盘链接)
- Filecoin最新动态 完成重大升级 已实现四大项目进展!
- Mongodb (from 0 to 1), 11 days mongodb primary to intermediate advanced secret
- Leetcode's ransom letter
猜你喜欢

How to encapsulate distributed locks more elegantly

Face to face Manual Chapter 16: explanation and implementation of fair lock of code peasant association lock and reentrantlock

一篇文章带你了解CSS3 背景知识

Can't be asked again! Reentrantlock source code, drawing a look together!

Vue 3 responsive Foundation

Thoughts on interview of Ali CCO project team

从海外进军中国,Rancher要执容器云市场牛耳 | 爱分析调研

速看!互联网、电商离线大数据分析最佳实践!(附网盘链接)

数字城市响应相关国家政策大力发展数字孪生平台的建设

前端都应懂的入门基础-github基础
随机推荐
PN8162 20W PD快充芯片,PD快充充电器方案
数据产品不就是报表吗?大错特错!这分类里有大学问
[event center azure event hub] interpretation of error information found in event hub logs
采购供应商系统是什么?采购供应商管理平台解决方案
(2)ASP.NET Core3.1 Ocelot路由
It's so embarrassing, fans broke ten thousand, used for a year!
Multi classification of unbalanced text using AWS sagemaker blazingtext
Calculation script for time series data
How to use parameters in ES6
Wiremock: a powerful tool for API testing
React design pattern: in depth understanding of react & Redux principle
至联云分享:IPFS/Filecoin值不值得投资?
一篇文章带你了解CSS3图片边框
The choice of enterprise database is usually decided by the system architect - the newstack
至联云解析:IPFS/Filecoin挖矿为什么这么难?
axios学习笔记(二):轻松弄懂XHR的使用及如何封装简易axios
一篇文章带你了解HTML表格及其主要属性介绍
阿里云Q2营收破纪录背后,云的打开方式正在重塑
Natural language processing - BM25 commonly used in search
How to become a data scientist? - kdnuggets