Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.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 FileNotFoundError:[WinError 2]系统找不到指定的文件/tempfile_Python_Temporary Files - Fatal编程技术网

Python FileNotFoundError:[WinError 2]系统找不到指定的文件/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

我需要获取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 = 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,如果不只是创建一个空目录,请确保其中一个目录存在。