Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python全局精确模式匹配_Python_Glob - Fatal编程技术网

Python全局精确模式匹配

Python全局精确模式匹配,python,glob,Python,Glob,您好,我有下面的代码,我试图排除精确的字符串匹配,但它没有给出我想要的结果,例如,如果我的文件名是xyz_20200720.xlsx,下面的代码将排除xyz_20200720.xlsx,因为模式匹配中有一个“2”。总而言之,我试图忽略名称中有月末日期的文件 import glob import os import shutil cleanlist = glob.glob('F://SM//Portfolio Monitoring//TABLEAU//ACTIVE PIPELINE//MON

您好,我有下面的代码,我试图排除精确的字符串匹配,但它没有给出我想要的结果,例如,如果我的文件名是xyz_20200720.xlsx,下面的代码将排除xyz_20200720.xlsx,因为模式匹配中有一个“2”。总而言之,我试图忽略名称中有月末日期的文件


import glob
import os
import shutil


cleanlist = glob.glob('F://SM//Portfolio Monitoring//TABLEAU//ACTIVE PIPELINE//MONTH END PIPELINE FILES//**/*[!|31|0228|0430|0630|1130].xlsx',recursive=True)
print(cleanlist)
maxclean = max(cleanlist, key=os.path.getctime)
print(maxclean)
os.remove(maxclean)

movelist = glob.glob('F://SM//Portfolio Monitoring//TABLEAU//ACTIVE PIPELINE//DATE SPECIFIC//*') 
filetomove = max(movelist, key=os.path.getctime)

targetpath = 'F://SM//Portfolio Monitoring//TABLEAU//ACTIVE PIPELINE//MONTH END PIPELINE FILES//'

shutil.copy(filetomove, targetpath)