- 博客(7)
- 收藏
- 关注
原创 numpy的保存与读取
import os import numpy as np os.chdir('C:/Users/Administrator/Desktop') #更改工作目录 ar = np.random.rand(5,5) #生成5*5的0-1的数组 np.savetxt('test.txt',ar,delimiter=',',fmt='%.2f') #保存...
2019-01-17 14:47:54
212
原创 【备忘】.find查找中文
>>>a='我是谁' >>>a.find(u'是') 1
2018-11-26 16:17:29
1135
原创 【小应用】批量修改txt内容
import os with open('1.txt','r') as f: #打开原文件 with open('new.txt','w') as ff: #创新新文件 for line in f.readlines(): #逐行读取 if line[0] !='-': #读取首字符不是‘-‘的行 ...
2018-09-21 15:58:28
3018
原创 Python基础学习【3】
字符串方法 1.center居中字符串,根据width两侧填充 >>>'apple'.center(8) #ljust\rjust\zfill 末尾填充\首填充\用0首填充 '_apple__' #'_'代表空格 2.find查找字符串,返回索引(lfind\rfind 从首查\从尾查) >>>'apple banana orange'.find...
2018-09-07 12:13:35
165
原创 Python基础学习【2】
字符串基础 >>>'hello,%s!' % ('mo') # 'xxx %s' % ('ss') %作为标识符 'hello,mo!' >>>'{foo}{bar}'.format(bar=4,foo=3) #按字段名ba
2018-09-06 18:40:54
146
原创 Python基础学习【1】
#List基础知识 1.append在列表末尾添加对象 >>>a=[1,2,3] >>>a.append(4) >>>a [1,2,3,4] 2.clear清空列表
2018-09-04 10:21:55
275
原创 OS模块学习
import os,shutil src_path='D:/00-test' dst_path='D:/00-test/pic' os.rmdir('D:/00-test/pic') os.mkdir('D:/00-test/pic') #读取模块 #将关键词的文件,导入列表 list=[] for file in os.listdir('D:/00-test'): i...
2018-08-29 11:28:22
197
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅