ategicprint语句显示变量的值,并与您期望的值进行比较。不过,这是基于使用print语句的一个路径字符串,当作为字符串列表引入时,输入=/=输出。我对这个问题的假设是,我在字符串列表中添加了等价的path,在python将path读入字符串的过程中
ategicprint语句显示变量的值,并与您期望的值进行比较。不过,这是基于使用print语句的一个路径字符串,当作为字符串列表引入时,输入=/=输出。我对这个问题的假设是,我在字符串列表中添加了等价的path,在python将path读入字符串的过程中,python,Python,ategicprint语句显示变量的值,并与您期望的值进行比较。不过,这是基于使用print语句的一个路径字符串,当作为字符串列表引入时,输入=/=输出。我对这个问题的假设是,我在字符串列表中添加了等价的path,在python将path读入字符串的过程中,如果这有意义的话,它基本上变成了path*。因此,Skip\u Fld将永远不会包含path项,因为path*项是迭代的项。我以前解决这个问题的唯一方法是使用原始字符串来处理文件路径,但我不知道如何在构建列表时实现这一点。同样,如果脚本可以简
ategic
print
语句显示变量的值,并与您期望的值进行比较。不过,这是基于使用print
语句的一个路径字符串,当作为字符串列表引入时,输入=/=输出。我对这个问题的假设是,我在字符串列表中添加了等价的path
,在python将path
读入字符串的过程中,如果这有意义的话,它基本上变成了path*
。因此,Skip\u Fld
将永远不会包含path
项,因为path*
项是迭代的项。我以前解决这个问题的唯一方法是使用原始字符串来处理文件路径,但我不知道如何在构建列表时实现这一点。同样,如果脚本可以简化为a,并且您可以在问题中提及甚至演示这一观察结果,您就更有可能获得帮助以获得解决方案。令人讨厌的GUI尤其掩盖了问题,因为很难准确地知道如何重现您的问题。取出所有活动零件,以便只留下问题。
A:\\stuff\a\b\
A:\\junk\a\b\
A
B
import os
from tkinter import filedialog
import fnmatch
input('Press Enter to select any file in writing directory or associated control files...')
fname = filedialog.askopenfilename()
fpath = os.path.split(fname)
# Set location for Drive Locations to scan
Disk_Locations = os.path.join(fpath[0], r'Drive_Locations.txt')
# Set location for Folders to ignore such as program files
Ignore = os.path.join(fpath[0], r'Folders_To_Skip.txt')
# Opens list of Drive Locations to be sampled
with open(Disk_Locations, 'r') as Drives:
Drive = Drives.readlines()
Drive = [x.replace('\n', '') for x in Drive]
# Iterable list for directories to be excluded
with open(Ignore, 'r') as SkipF1:
Skip_Fld = SkipF1.readlines()
Skip_Fld = [x.replace('\n', '') for x in Skip_Fld]
# Locates file in entire file tree from previously established parent directory.
def locate(pattern, root=os.curdir):
for path, dirs, files in os.walk(os.path.abspath(root), topdown=True):
dirs[:] = [d for d in dirs if d not in Skip_Fld]
for filename in fnmatch.filter(files, pattern):
yield os.path.join(path, filename)
for disk in Drive:
# Formats Drive Location for acceptance
disk = str.upper(disk)
if str.find(disk, ':') < 0:
disk = disk + ':'
# Changes the current disk drive
if os.path.exists(disk):
os.chdir(disk)
# If disk incorrect skip to next disk
else:
continue
for exist_csv in locate('*.csv'):
# Skip compiled record output files in search
print(exist_csv)