- 博客(14)
- 收藏
- 关注
原创 python安装Carpoty
去这里下载自己版本python的GEOS,shapely,pyshp,pyproj;安装上面的依赖库完了再下载安装cartopy;
2024-07-13 17:37:11 152
原创 error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“:
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“:
2022-08-01 16:24:52 400
原创 清理文本
def clean_text(text): text = text.lower() # lowercase text = re.sub(r'[!]+', '!', text) text = re.sub(r'[?]+', '?', text) text = re.sub(r'[.]+', '.', text) text = re.sub(r"'", "", text) text = re.sub('\s+', ' ', text).strip() # R
2021-03-09 14:53:37 188
原创 替换特定字符
替换特定字符import oswith open(r'input.txt', 'r', encoding='utf-8') as f: countent = f.readlines() for line in countent: countent = line.replace("A","B")#把A换成B with open(r'output.txt', "a+", encoding='utf-8') as fa: fa.writ
2021-03-06 12:43:13 88
原创 去除小于一定长度的数据条目
去除小于一定长度的数据条目import ref=open(r"input.csv",'r',encoding='utf-8')alllines=f.readlines()f.close()f=open(r"output.csv",'w+',encoding='utf-8')for eachline in alllines: a = eachline try: b = list(a) c = b[0] if c !=' ':
2021-03-06 12:40:36 223
原创 从文本中随机抽取部分数据
从文本中随机抽取部分数据# coding:utf-8import randomimport time"""注意盘符小写"""DATA_DIR = r'D:\\'DATA_DIR2 = r'D:\\hello.txt'a = range(3)def test(): for item in a: f = open("13fix.txt", "r", encoding='utf-8') # 源文件 fw = open("hello.txt",
2021-03-06 12:38:29 419
原创 分割文本为三不等部分
分割你的训练文本with open(r"要处理的原文本.txt",'r',encoding='utf-8') as f: countent = f.readlines() count = 0 # pat = re.compile('\n') for line in countent: count=count+1 if 0<=count<=(数字:第一部分数据条数): with open(r"train.t
2021-03-06 12:36:10 96
原创 删除不必要字符
删除不必要字符(如空格)import ref=open(r"1.txt",'r',encoding='utf-8')alllines=f.readlines()f.close()f=open(r"output.txt",'w+',encoding='utf-8')for eachline in alllines: a=re.sub(' ','. ',eachline) f.writelines(a)f.close()
2021-03-06 12:33:36 96
原创 合并两个txt文档
合并两个txt文档file1 = open(r"1.txt", "r",encoding='utf-8')file2 = open(r"2.txt", "r",encoding='utf-8')file1_lists = file1.readlines()file2_lists = file2.readlines()file3_list = []file4_list = []for i in file1_lists: temp_list = i.split() file3_
2021-03-06 12:32:12 415
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人