Python FileNotFoundError:[WinError 2]系统找不到指定的文件/tempfile
我需要获取16位摄影测量目标,因此我尝试使用此wedsite:中的代码,但它在尝试使用tempfile创建临时目录时出错,我似乎不明白为什么Python FileNotFoundError:[WinError 2]系统找不到指定的文件/tempfile,python,temporary-files,Python,Temporary Files,我需要获取16位摄影测量目标,因此我尝试使用此wedsite:中的代码,但它在尝试使用tempfile创建临时目录时出错,我似乎不明白为什么 with tempfile.TemporaryDirectory() as tmp_dir: # Create sheets of targets in temporary directory pdfs = [] for n in range(math.ceil(len(CODES) / ROWS / COLUMNS)): pdf_filename
with tempfile.TemporaryDirectory() as tmp_dir:
# Create sheets of targets in temporary directory
pdfs = []
for n in range(math.ceil(len(CODES) / ROWS / COLUMNS)):
pdf_filename = os.path.join(tmp_dir, str(n) + '.pdf')
create_sheet(n, pdf_filename)
pdfs.append(pdf_filename)
# Combine sheets into a single PDF
subprocess.run(['pdftk'] + pdfs + ['cat', 'output', FILENAME])
也许
FILENAME
应该是pdf\u FILENAME
?您还需要先创建文件,然后再开始附加到该文件。tempfile
在Windows上查找C:\TEMP、C:\TMP、\TEMP或\TMP,如果不只是创建一个空目录,请确保其中一个目录存在。