我搜索了高低,但正在努力使用以下代码。在底部的 for 循环中,我需要遍历多维列表的第一个元素中的名称。我对 Python 很陌生,所以请原谅我的无知。
for file in files: # loop thru each recording
file_with_path = recording_fullpath + "/" + file #construct full file path
file_mtime = modification_date(file_with_path) # obtain file mod date
if file_mtime >= start_date and file_mtime <= end_date:
#print file + " is within the time range " + str(file_mtime)
archive_list[count].append (file_with_path)
archive_list[count].append (recording_subdir) # append filename with path to list
archive_list.append([])
count =+ 1
tarname = tar_path + "/" + client_id + "_" + dt.datetime.now().strftime("%Y%m%d_%H%M%S") + ".tar.gz"
print tarname
tar = tarfile.open (tarname, "w:gz")
for name in archive_list[][]:
print "Adding %s" % (name)
tar.add(name, arcname=client_id)
tar.close()
当我只使用单个元素数组但无法计算出包含第二列的语法时,此代码有效。