![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 97
robberM
这个作者很懒,什么都没留下…
展开
-
Python 的一些tricks
1. numpy 拼接def get_features(path): features = [] files = sh.find(path, '-type', 'f', '-name', '*.npy') files = [f.strip() for f in files] features = np.concatenate([np.load(f) for f in files], axis=0) return features原创 2020-05-26 19:30:49 · 445 阅读 · 0 评论 -
python处理fft
import numpy as np from scipy.fftpack import fft, fftshift, ifftfrom scipy.fftpack import fftfreqimport numpy as npimport matplotlib.pyplot as plt%matplotlib inlineimport osdef read_txt(f): ...原创 2020-03-02 15:41:52 · 655 阅读 · 0 评论 -
python文本txt处理
读操作总结写在前面,三个方法:read() + splitlines()readlines() + strip()readline() + 循环假设有test.txt文件内容为:banana,apple,orangecat, dog, pigfather, mother, childman, woman, human三种写法:1. read()方法with open(...原创 2019-12-26 14:47:33 · 2592 阅读 · 1 评论 -
python 读写txt文件 json文件
首先第一步,打开文件,有两个函数可供选择:open() 和 file() ①. f = open('file.txt',‘w’) ... file.close() ②. f = file('file.json','r')... file.close()原创 2014-02-14 21:00:47 · 13057 阅读 · 0 评论 -
python文件属性判断(是否存在,是否为空)
1. 判断文件是否为空os.path.getsize()返回文件的字节数,如果为0,则代表空。import osfile = "/home/abc/a.txt"if not os.path.getsize(file): os.remove(file)2. 判断文件/文件夹是否存在os.path.exists()方法用于检验文件/文件夹是否存在。import o...原创 2019-08-25 08:39:40 · 13229 阅读 · 1 评论