当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Skywalking series blog 2-skywalking using
- EOS创始人BM: UE,UBI,URI有什么区别?
- I've been rejected by the product manager. Why don't you know
- 一篇文章带你了解HTML表格及其主要属性介绍
- Network security engineer Demo: the original * * is to get your computer administrator rights! 【***】
- React design pattern: in depth understanding of react & Redux principle
- Working principle of gradient descent algorithm in machine learning
- Use of vuepress
- Keyboard entry lottery random draw
- From zero learning artificial intelligence, open the road of career planning!
猜你喜欢
PHP应用对接Justswap专用开发包【JustSwap.PHP】
合约交易系统开发|智能合约交易平台搭建
Windows 10 tensorflow (2) regression analysis of principles, deep learning framework (gradient descent method to solve regression parameters)
Not long after graduation, he earned 20000 yuan from private work!
Summary of common string algorithms
加速「全民直播」洪流,如何攻克延时、卡顿、高并发难题?
阿里云Q2营收破纪录背后,云的打开方式正在重塑
Vue 3 responsive Foundation
做外包真的很难,身为外包的我也无奈叹息。
一篇文章带你了解CSS对齐方式
随机推荐
Keyboard entry lottery random draw
6.4 viewresolver view parser (in-depth analysis of SSM and project practice)
It's so embarrassing, fans broke ten thousand, used for a year!
Use of vuepress
嘗試從零開始構建我的商城 (二) :使用JWT保護我們的資訊保安,完善Swagger配置
5.4 static resource mapping
Python + appium automatic operation wechat is enough
The road of C + + Learning: from introduction to mastery
How to select the evaluation index of classification model
Programmer introspection checklist
Group count - word length
如何玩转sortablejs-vuedraggable实现表单嵌套拖拽功能
The difference between Es5 class and ES6 class
Working principle of gradient descent algorithm in machine learning
6.2 handleradapter adapter processor (in-depth analysis of SSM and project practice)
Brief introduction and advantages and disadvantages of deepwalk model
每个前端工程师都应该懂的前端性能优化总结:
阿里云Q2营收破纪录背后,云的打开方式正在重塑
Process analysis of Python authentication mechanism based on JWT
Swagger 3.0 天天刷屏,真的香嗎?