首页 >>  正文

python删除字符串元素

来源:baiyundou.net   日期:2024-09-23

作者:大橡皮啊

          由于自己瞎鼓捣Mentens,导致Drive里的重复照片和视频越来越多了.于是便使用存储空间分析器,看一下有哪些重复的照片和视频(存储空间分析器安装很简单,打开套件中心搜索 存储空间分析器,按就行了).

多图预警 

        分析是分析完了.也可以在分析器里手动删除(你要真这样删除,我也无话可说.毕竟我又不是二傻子...... )

Python脚本实现文件MD5对比

首先,我们要先从分析报告里获取到已经筛选出的重复文件路径.

我们的分析器报告存储的位置是volume2中,所以我的报告的完整路径应该是:/volume2/strong_report/synoreport/ReaptPhoto/2022-11-02_11-22-21/csv

前面是固定的路径不变,只有2022-11-02_11-22-21 这个是随着每次分析时,按照当前时间命名的文件夹.我们可以利用os.listdir(path)来获取这个文件夹的名字.完成拼接.

拼接完成后,就是解压缩包含csv的zip文件.然后利用字符串分割,把文件路径取出来,进行MD5和文件名长度的对比.最后再进行删除操作.

把python脚本上传到一个目录里

添加计划任务(计划任务的时间要比分析器执行的时间往后去,要先分析文件,再进行删除).

然后运行一下计划任务,看看结果如何. 这个结果是在邮件里哟.

不让放下载地址.咋整?

","force_purephv":"0","gnid":"9d8192bb9ba420f91","img_data":[{"flag":2,"img":[{"desc":"","height":"849","title":"","url":"https://p0.ssl.img.360kuai.com/t011d13ebf95d7780f7.jpg","width":"503"},{"desc":"","height":"368","title":"","url":"https://p0.ssl.img.360kuai.com/t01e403f64dd986c5fe.jpg","width":"600"},{"desc":"","height":"351","title":"","url":"https://p0.ssl.img.360kuai.com/t01ecfe0fabea7430a6.jpg","width":"600"},{"desc":"","height":"369","title":"","url":"https://p0.ssl.img.360kuai.com/t0151f112d9fd0c4a01.jpg","width":"600"},{"desc":"","height":"356","title":"","url":"https://p0.ssl.img.360kuai.com/t012b33229edd563050.jpg","width":"600"},{"desc":"","height":"375","title":"","url":"https://p0.ssl.img.360kuai.com/t0187b38eb206d9aac6.jpg","width":"600"},{"desc":"","height":"363","title":"","url":"https://p0.ssl.img.360kuai.com/t0173541854d128710c.jpg","width":"600"},{"desc":"","height":"344","title":"","url":"https://p0.ssl.img.360kuai.com/t012574262fe29a6153.jpg","width":"600"},{"desc":"","height":"343","title":"","url":"https://p0.ssl.img.360kuai.com/t013b4c0a7cc4b54e49.jpg","width":"600"},{"desc":"","height":"353","title":"","url":"https://p0.ssl.img.360kuai.com/t01e69d3746ce39235e.jpg","width":"600"},{"desc":"","height":"351","title":"","url":"https://p0.ssl.img.360kuai.com/t01a8091599dfaaf659.jpg","width":"600"},{"desc":"","height":"276","title":"","url":"https://p0.ssl.img.360kuai.com/t01017dd0d651e91bf9.jpg","width":"600"},{"desc":"","height":"193","title":"","url":"https://p0.ssl.img.360kuai.com/t01125fe7eb3deaf405.jpg","width":"600"},{"desc":"","height":"346","title":"","url":"https://p0.ssl.img.360kuai.com/t01b026327f258af4ab.jpg","width":"600"},{"desc":"","height":"336","title":"","url":"https://p0.ssl.img.360kuai.com/t01771c704b25a5f856.jpg","width":"600"},{"desc":"","height":"159","title":"","url":"https://p0.ssl.img.360kuai.com/t01cdb45c8674f1e1fa.jpg","width":"600"}]}],"original":0,"pat":"art_src_1,fts0,sts0","powerby":"hbase","pub_time":1668160462000,"pure":"","rawurl":"http://zm.news.so.com/5047991e9bce187f2f8be6926bdb9864","redirect":0,"rptid":"6ffbf128b48cac0e","s":"t","src":"什么值得买","tag":[],"title":"黑群晖利用存储空间分析器和python脚本,删除重复的文件

曲程东1912Python 删除列表中的字符串 -
邹追别18484699772 ______ 用正则批量替换.

曲程东1912python中如何去除字符串中的数字 -
邹追别18484699772 ______ import res = 'speed=210,angle=150'm = re.findall(r'(\w*[0-9]+)\w*',s)print m结果: >>> import re >>> s = 'speed=210,angle=150' >>> m = re.findall(r'(\w*[0-9]+)\w*',s) >>> print m ['210', '150'] >>>

曲程东1912python如何删除字符串中指定位置的字符 -
邹追别18484699772 ______ #!/bin/env pythonimport shutil, sys, osdarray = [ "Entering directory", "In function ", "Leaving directory", "__NR_SYSCALL_BASE", "arm-hisiv100-linux-ar ", "arm-hisiv100-linux-gcc ", "but argument is of type", "dereferencing type...

曲程东1912python 删除字符 -
邹追别18484699772 ______ import structa="abcdefg"b=raw_input()print a.replace(b, '') python2这么写,python3要用input,并且print的东西要加括号,比如print('123')

曲程东1912python 字符串 删除重复的数据 -
邹追别18484699772 ______ str3 = list(set(str2) - set(str1))

曲程东1912python如何删除字符串中指定位置的字符 -
邹追别18484699772 ______ 不用转list.python可以很方便地操作字符串.s = s[:3] + s[4:]

曲程东1912python3中如何用re.sub,删除掉字符串中的'['、']'这两个符号? -
邹追别18484699772 ______ python打印列表本来就带了[]符号 如果要去掉你最好用循环单个打印内部的元素

曲程东1912python 去除如下字符串中 的所有中括号 -
邹追别18484699772 ______ 用Python的replace函数就可以去除字符串中的所有中括号 完整的Python程序如下 #!/usr/bin/python str = ' [[[[239, 267]], [[238, 268]], [[237, 268]], [[236, 269]], [[235, 269]], [[234, 270]], [[233, 270]], [[232, 271]], [[232, 281]],[[240, 289]], [[241, 289]], [[...

曲程东1912python替换最后一个字符 -
邹追别18484699772 ______ def rep_split(infile,spliter,repter): with open(infile,'r') as sp_file: for line in sp_file: newline=line[::-1].replace(spliter,repter,1)[::-1] print(newline) #open('out.txt','a').writelines(outline) rep_split('1kk.txt','\\',' ') 函数参数说明:第一个为输入文件,第二个为需要替换的分隔符,第三个为目标替换符号 效果如下 >>> a\b\ccc ddd xxx\y zzz q w

(编辑:自媒体)
关于我们 | 客户服务 | 服务条款 | 联系我们 | 免责声明 | 网站地图 @ 白云都 2024