如何使用名称创建多个文件夹,并将多个zips提取到每个不同的文件夹,使用python? -- python 领域 和 directory 领域 和 zip 领域 和 extract 领域 相关 的问题

How to create multiple folders with names, and extract multiple zips to each different folder, with python?


3
vote

问题

中文

我无法创建许多不同的目录,了解包含不同栅格数据的许多不同的ZIP文件夹,然后将所有zips从清洁脚本中的新文件夹中提取到新文件夹。

我已经完成了我的代码的任务是非常长而凌乱的。我需要具有标有 99887663 99887664 等的文件夹,然后在这些目录中,我需要子文件夹,例如 99887665 ,<代码> N34_25 等栅格数据将被提取到。我有超过100个需要提取并放置在子文件夹中的zip文件。

在对我正在制作目录的方式进行一些更改后,这是我脚本的一个样本。

我的文件结构如下:

  N\N36_E\N36_24 N\N36_E\N35_25 ... etc.   

zipfile名称:

  n36_e024_1arc_v3_bil.zip n36_e025_1arc_v3_bil.zip n36_e026_1arc_v3_bil.zip ... etc.   

python代码创建目录结构:

  import os  #Create Sub directories for "NE36_" pathname1 = "NE36_" pathname2 = 24 directory = "D:\Capstone\Test\N36_E\" + str(pathname1) + str(pathname2) while pathname2 < 46:     if not os.path.exists(directory):         os.makedirs(directory)     pathname2 += 1     directory = "D:\Capstone\Test\N36_E\" + str(pathname1) + str(pathname2)  #Create Sub directories for "NE37_" pathname1 = "NE37_" pathname2 = 24 directory = "D:\Capstone\Test\N37_E\" + str(pathname1) + str(pathname2) while pathname2 < 46:     if not os.path.exists(directory):         os.makedirs(directory)     pathname2 += 1     directory = "D:\Capstone\Test\N37_E\" + str(pathname1) + str(pathname2)   
英文原文

I'm having trouble creating many different directories for a number of different zip folders containing different raster data and then extracting all the zips to the new folders in a clean script.

I have accomplished my task by my code is very long and messy. I need to have folders that are labeled like NE34_E , NE35_E etc, and then within these directories, I need subfolders such as N34_24 , N34_25 etc. which the raster data will be extracted to. I have over 100 zip files that need to be extracted and placed in subfolders.

After making some changes to the way I was making directories this is a sample of my script.

My file structure goes like this:

N\\N36_E\\N36_24 N\\N36_E\\N35_25 ... etc. 

Zipfile names:

n36_e024_1arc_v3_bil.zip n36_e025_1arc_v3_bil.zip n36_e026_1arc_v3_bil.zip ... etc. 

Python code to create the directory structure:

import os  #Create Sub directories for "NE36_" pathname1 = "NE36_" pathname2 = 24 directory = "D:\\Capstone\\Test\\N36_E\\" + str(pathname1) + str(pathname2) while pathname2 < 46:     if not os.path.exists(directory):         os.makedirs(directory)     pathname2 += 1     directory = "D:\\Capstone\\Test\\N36_E\\" + str(pathname1) + str(pathname2)  #Create Sub directories for "NE37_" pathname1 = "NE37_" pathname2 = 24 directory = "D:\\Capstone\\Test\\N37_E\\" + str(pathname1) + str(pathname2) while pathname2 < 46:     if not os.path.exists(directory):         os.makedirs(directory)     pathname2 += 1     directory = "D:\\Capstone\\Test\\N37_E\\" + str(pathname1) + str(pathname2) 
           
 
 

回答列表

1
 
vote
vote
最佳答案
 
  import glob, os, re, zipfile  # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest'  # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)')  for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')):      # Get the parts from the base zip filename using regular expressions.     part = re.findall(re_pattern, os.path.basename(zip_file))[0]      # Make all items in part uppercase using a list comprehension.     part = [item.upper() for item in part]      # Create a dict of the parts to make useful parts to be used for folder names.     # E.g. from ['N', '36', 'E', '24']     folder = {'outer': '{0}{1}_{2}'.format(*part),               'inner': '{0}{2}{1}_{3}'.format(*part)}      # Build the extraction path from each part.     extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner'])      # Perform the extract of all files from the zipfile.     with zipfile.ZipFile(zip_file, 'r') as zip:         zip.extractall(extract_path)   

2设置值的主要设置,即:

  1. zipfile_rootdir 是zip文件所在的位置。
  2. extract_rootdir 是提取到的地方。

r 在字符串作为原始字符串中进行处理之前, 所以不需要反斜杠逃避。

编译正则表达式并用于提取 用于zip文件名的文本 提取路径。

从zip文件:

  n36_e024_1arc_v3_bil.zip   

利用正则表达式提取部分序列:

  n, 36, e, 24   

每个项目都是updoased并用于创建字典 命名为 folders 包含键和值:

  fid = fopen(filename,'r',MACHINEFORMAT); data = fread(fid,inf,'float32');  %float32 is for single precision float 0  

fid = fopen(filename,'r',MACHINEFORMAT); data = fread(fid,inf,'float32'); %float32 is for single precision float 1 将通过加入存储完整路径 fid = fopen(filename,'r',MACHINEFORMAT); data = fread(fid,inf,'float32'); %float32 is for single precision float 2 fid = fopen(filename,'r',MACHINEFORMAT); data = fread(fid,inf,'float32'); %float32 is for single precision float 3 fid = fopen(filename,'r',MACHINEFORMAT); data = fread(fid,inf,'float32'); %float32 is for single precision float 4

最后,通过使用 998876615 使用上下文管理器,将提取zip文件。


正则表达式:

  fid = fopen(filename,'r',MACHINEFORMAT); data = fread(fid,inf,'float32');  %float32 is for single precision float 6  

之前的正则表达式图案的编译 循环是避免多次编译模式 在循环。 使用 fid = fopen(filename,'r',MACHINEFORMAT); data = fread(fid,inf,'float32'); %float32 is for single precision float 7 在字符串之前通知Python 那个字符串应该被解释为原始 即,没有反斜杠逃脱。 原始字符串对正则表达式有用 反斜杠逃避用于模式。

正则表达式模式:

  fid = fopen(filename,'r',MACHINEFORMAT); data = fread(fid,inf,'float32');  %float32 is for single precision float 8  

正常表达式工作的字符串:

  fid = fopen(filename,'r',MACHINEFORMAT); data = fread(fid,inf,'float32');  %float32 is for single precision float 9  
  1. data = fread(fid,[M,inf],'float32'); 0 仅在字符串开始时匹配。 这是一个锚,不匹配任何字符。
  2. data = fread(fid,[M,inf],'float32'); 1 匹配任何字母字符。 data = fread(fid,[M,inf],'float32'); 2 与内部的任何字符匹配。 data = fread(fid,[M,inf],'float32'); 3的范围之间的任何字符 data = fread(fid,[M,inf],'float32'); 4 data = fread(fid,[M,inf],'float32'); 5 data = fread(fid,[M,inf],'float32'); 6 匹配。 data = fread(fid,[M,inf],'float32'); 7 将匹配。 附带 data = fread(fid,[M,inf],'float32'); 8 是捕获的组的存储 返回的序列。所以序列现在 data = fread(fid,[M,inf],'float32'); 9
  3. import glob, os, re, zipfile # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest' # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)') for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')): # Get the parts from the base zip filename using regular expressions. part = re.findall(re_pattern, os.path.basename(zip_file))[0] # Make all items in part uppercase using a list comprehension. part = [item.upper() for item in part] # Create a dict of the parts to make useful parts to be used for folder names. # E.g. from ['N', '36', 'E', '24'] folder = {'outer': '{0}{1}_{2}'.format(*part), 'inner': '{0}{2}{1}_{3}'.format(*part)} # Build the extraction path from each part. extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner']) # Perform the extract of all files from the zipfile. with zipfile.ZipFile(zip_file, 'r') as zip: zip.extractall(extract_path) 0 匹配1位或更多。 import glob, os, re, zipfile # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest' # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)') for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')): # Get the parts from the base zip filename using regular expressions. part = re.findall(re_pattern, os.path.basename(zip_file))[0] # Make all items in part uppercase using a list comprehension. part = [item.upper() for item in part] # Create a dict of the parts to make useful parts to be used for folder names. # E.g. from ['N', '36', 'E', '24'] folder = {'outer': '{0}{1}_{2}'.format(*part), 'inner': '{0}{2}{1}_{3}'.format(*part)} # Build the extraction path from each part. extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner']) # Perform the extract of all files from the zipfile. with zipfile.ZipFile(zip_file, 'r') as zip: zip.extractall(extract_path) 1 是任何数字 import glob, os, re, zipfile # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest' # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)') for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')): # Get the parts from the base zip filename using regular expressions. part = re.findall(re_pattern, os.path.basename(zip_file))[0] # Make all items in part uppercase using a list comprehension. part = [item.upper() for item in part] # Create a dict of the parts to make useful parts to be used for folder names. # E.g. from ['N', '36', 'E', '24'] folder = {'outer': '{0}{1}_{2}'.format(*part), 'inner': '{0}{2}{1}_{3}'.format(*part)} # Build the extraction path from each part. extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner']) # Perform the extract of all files from the zipfile. with zipfile.ZipFile(zip_file, 'r') as zip: zip.extractall(extract_path) 2 告诉它符合更多。 序列变为 import glob, os, re, zipfile # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest' # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)') for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')): # Get the parts from the base zip filename using regular expressions. part = re.findall(re_pattern, os.path.basename(zip_file))[0] # Make all items in part uppercase using a list comprehension. part = [item.upper() for item in part] # Create a dict of the parts to make useful parts to be used for folder names. # E.g. from ['N', '36', 'E', '24'] folder = {'outer': '{0}{1}_{2}'.format(*part), 'inner': '{0}{2}{1}_{3}'.format(*part)} # Build the extraction path from each part. extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner']) # Perform the extract of all files from the zipfile. with zipfile.ZipFile(zip_file, 'r') as zip: zip.extractall(extract_path) 3
  4. import glob, os, re, zipfile # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest' # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)') for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')): # Get the parts from the base zip filename using regular expressions. part = re.findall(re_pattern, os.path.basename(zip_file))[0] # Make all items in part uppercase using a list comprehension. part = [item.upper() for item in part] # Create a dict of the parts to make useful parts to be used for folder names. # E.g. from ['N', '36', 'E', '24'] folder = {'outer': '{0}{1}_{2}'.format(*part), 'inner': '{0}{2}{1}_{3}'.format(*part)} # Build the extraction path from each part. extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner']) # Perform the extract of all files from the zipfile. with zipfile.ZipFile(zip_file, 'r') as zip: zip.extractall(extract_path) 4 是文字,因为 import glob, os, re, zipfile # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest' # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)') for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')): # Get the parts from the base zip filename using regular expressions. part = re.findall(re_pattern, os.path.basename(zip_file))[0] # Make all items in part uppercase using a list comprehension. part = [item.upper() for item in part] # Create a dict of the parts to make useful parts to be used for folder names. # E.g. from ['N', '36', 'E', '24'] folder = {'outer': '{0}{1}_{2}'.format(*part), 'inner': '{0}{2}{1}_{3}'.format(*part)} # Build the extraction path from each part. extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner']) # Perform the extract of all files from the zipfile. with zipfile.ZipFile(zip_file, 'r') as zip: zip.extractall(extract_path) 5 没有封闭它,它 匹配虽然未添加到序列中。
  5. import glob, os, re, zipfile # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest' # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)') for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')): # Get the parts from the base zip filename using regular expressions. part = re.findall(re_pattern, os.path.basename(zip_file))[0] # Make all items in part uppercase using a list comprehension. part = [item.upper() for item in part] # Create a dict of the parts to make useful parts to be used for folder names. # E.g. from ['N', '36', 'E', '24'] folder = {'outer': '{0}{1}_{2}'.format(*part), 'inner': '{0}{2}{1}_{3}'.format(*part)} # Build the extraction path from each part. extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner']) # Perform the extract of all files from the zipfile. with zipfile.ZipFile(zip_file, 'r') as zip: zip.extractall(extract_path) 6 与点2相同。 序列变为 import glob, os, re, zipfile # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest' # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)') for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')): # Get the parts from the base zip filename using regular expressions. part = re.findall(re_pattern, os.path.basename(zip_file))[0] # Make all items in part uppercase using a list comprehension. part = [item.upper() for item in part] # Create a dict of the parts to make useful parts to be used for folder names. # E.g. from ['N', '36', 'E', '24'] folder = {'outer': '{0}{1}_{2}'.format(*part), 'inner': '{0}{2}{1}_{3}'.format(*part)} # Build the extraction path from each part. extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner']) # Perform the extract of all files from the zipfile. with zipfile.ZipFile(zip_file, 'r') as zip: zip.extractall(extract_path) 7
  6. import glob, os, re, zipfile # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest' # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)') for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')): # Get the parts from the base zip filename using regular expressions. part = re.findall(re_pattern, os.path.basename(zip_file))[0] # Make all items in part uppercase using a list comprehension. part = [item.upper() for item in part] # Create a dict of the parts to make useful parts to be used for folder names. # E.g. from ['N', '36', 'E', '24'] folder = {'outer': '{0}{1}_{2}'.format(*part), 'inner': '{0}{2}{1}_{3}'.format(*part)} # Build the extraction path from each part. extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner']) # Perform the extract of all files from the zipfile. with zipfile.ZipFile(zip_file, 'r') as zip: zip.extractall(extract_path) 8 匹配零 import glob, os, re, zipfile # Setup main paths. zipfile_rootdir = r'D:Capstoneipfiles' extract_rootdir = r'D:CapstoneTest' # Process the zip files. re_pattern = re.compile(r'A([a-zA-Z])(d+)_([a-zA-Z])0{0,2}(d+)') for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')): # Get the parts from the base zip filename using regular expressions. part = re.findall(re_pattern, os.path.basename(zip_file))[0] # Make all items in part uppercase using a list comprehension. part = [item.upper() for item in part] # Create a dict of the parts to make useful parts to be used for folder names. # E.g. from ['N', '36', 'E', '24'] folder = {'outer': '{0}{1}_{2}'.format(*part), 'inner': '{0}{2}{1}_{3}'.format(*part)} # Build the extraction path from each part. extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner']) # Perform the extract of all files from the zipfile. with zipfile.ZipFile(zip_file, 'r') as zip: zip.extractall(extract_path) 9 ,零到2次 zipfile_rootdir0 。 没有 zipfile_rootdir1 ,所以没有添加到序列中。
  7. zipfile_rootdir2 与点3相同。 序列变为 zipfile_rootdir3
  8. 剩下的字符串被忽略为模式 已达到结束。这就是 998877644 的原因 使用所以模式无法从任何地方开始 进入不需要的字符串的末尾。

格式化:

序列是 zipfile_rootdir5 updocased后 通过列表理解。

  1. 模式 zipfile_rootdir6 是有序 zipfile_rootdir7 , 所以0是 zipfile_rootdir8 ,1是 zipfile_rootdir9 和2是 extract_rootdir0 extract_rootdir1 extract_rootdir2 是图案中的文字。
  2. 图案 extract_rootdir3 已订购 extract_rootdir4 。 0是 extract_rootdir5 ,2是 extract_rootdir6 ,1是 extract_rootdir7 和3是 extract_rootdir8 变成 extract_rootdir9

参考:

  • python 2:

    • re 模块为正则表达式。
    • format 用于格式化字符串的方法 。
    • 列表扫描用于序列中的大写项目 。
    • zipfile 模块,用于使用zip档案。

  • python 3:

    • e 用于正则表达式的模块。
    • format 用于格式化字符串的方法 。
    • 列表扫描用于序列中的大写项目 。
    • zipfile 模块,用于使用zip档案。
 
import glob, os, re, zipfile  # Setup main paths. zipfile_rootdir = r'D:\Capstone\Zipfiles' extract_rootdir = r'D:\Capstone\Test'  # Process the zip files. re_pattern = re.compile(r'\A([a-zA-Z])(\d+)_([a-zA-Z])0{0,2}(\d+)')  for zip_file in glob.iglob(os.path.join(zipfile_rootdir, '*.zip')):      # Get the parts from the base zip filename using regular expressions.     part = re.findall(re_pattern, os.path.basename(zip_file))[0]      # Make all items in part uppercase using a list comprehension.     part = [item.upper() for item in part]      # Create a dict of the parts to make useful parts to be used for folder names.     # E.g. from ['N', '36', 'E', '24']     folder = {'outer': '{0}{1}_{2}'.format(*part),               'inner': '{0}{2}{1}_{3}'.format(*part)}      # Build the extraction path from each part.     extract_path = os.path.join(extract_rootdir, folder['outer'], folder['inner'])      # Perform the extract of all files from the zipfile.     with zipfile.ZipFile(zip_file, 'r') as zip:         zip.extractall(extract_path) 

2 main settings to set values, which is:

  1. zipfile_rootdir is where the zip file are located.
  2. extract_rootdir is where to extract to.

The r before the string is treat as raw string, so backslash escaping is not needed.

A regular expression is compiled and used to extract the text from the zip file names used for the extraction path.

From zip file:

n36_e024_1arc_v3_bil.zip 

extracts a part sequence with use of a regular expression:

n, 36, e, 24 

Each item is uppercased and used to create a dictionary named folders containing keys and values:

'outer': 'N36_E' 'inner': 'NE36_24' 

extract_path will store the full path by joining extract_rootdir with folder['outer'] and folder['inner'].

Finally, using a Context Manager by use of with, the zip files will be extracted.


Regular Expression:

re_pattern = re.compile(r'\A([a-zA-Z])(\d+)_([a-zA-Z])0{0,2}(\d+)') 

The compile of the regular expression pattern before the loop is to avoid multiple compiles of the pattern in the loop. The use of r before the string is to inform Python that that the string should be interpreted as raw i.e. no backslash escaping. Raw strings are useful for regular expressions as backslash escaping is used for the patterns.

The regular expression pattern:

\A([a-zA-Z])(\d+)_([a-zA-Z])0{0,2}(\d+) 

The string for the regular expression to work on:

n36_e024_1arc_v3_bil.zip 
  1. \A Matches only at the start of the string. This is an anchor and does not match any character.
  2. ([a-zA-Z]) Matches any alphabet character. [] is match any characters within. Any character between the range of a to z and A to Z is matched. n will be matched. The enclosing () is store that group captured into the returned sequence. So the sequence is now n,.
  3. (\d+) Matches 1 digit or more. The \d is any digit and + tells it to keep matching more. Sequence becomes n, 36,.
  4. _ is literal and since () is not enclosing it, it is matched though is not added to the sequence.
  5. ([a-zA-Z]) Same as point 2. Sequence becomes n, 36, e,.
  6. 0{0,2} Match a zero 0, zero to 2 times {0,2}. No (), so not added to the sequence.
  7. (\d+) Same as point 3. Sequence becomes n, 36, e, 24.
  8. The rest of the string is ignored as the pattern has reached it's end. This is why the \A is used so the pattern cannot start anywhere and proceed to the end of the string that is not wanted.

Formatting:

Sequence is N, 36, E, 24 after being uppercased by the list comprehension.

  1. The pattern {0}{1}_{2} is ordered 0, 1, 2, so 0 is N, 1 is 36 and 2 is E to become N36_E. The _ is literal in the pattern.
  2. The pattern {0}{2}{1}_{3} is ordered 0, 2, 1, 3. 0 is N, 2 is E, 1 is 36 and 3 is 24 to become NE36_24.

References:

  • Python 2:

    • re module for the regular expressions.
    • format method for the formatting of strings.
    • list comprehensions used to uppercase items in the sequence.
    • zipfile module for working with zip archives.
  • Python 3:

    • re module for the regular expressions.
    • format method for the formatting of strings.
    • list comprehensions used to uppercase items in the sequence.
    • zipfile module for working with zip archives.
 
 
         
         

相关问题

0  腌制物体的大小wrt gae blobproperty  ( Size of pickled object wrt gae blobproperty ) 
我正在挑痒一个python dictonary,并将它存储到gae blobproperty。 blobproperty有一个 1mb大小限制。我想以编程方式检查我的对象将在1MB限制中'fit'。 var_dump($ECB_rates); 5 但是len(pickled_object)测量是什么? (字符...

2  rq工作人员扔“valueerror”  ( Rq worker throwing valueerror ) 
我试图在我的烧瓶申请上获取RQ / RQ工作者。我试图将其缩至一个非常简单的测试用例。这是一般的想法: 用户访问 /test 页面。触发要排队的作业并返回排队作业的 job_key 工人( worker.py )处理排队的作业。 用户可以访问 /retrieve/<job_key> 页面来检索结果。 [这未显示...

1  在Python中转换秒和时间  ( Convert seconds to date and time in python ) 
我有一个包含秒的列的数据帧,我想将列转换为日期和时间,并使用包含日期和时间的列保存文件.I在几秒钟内有一个列的列 time 2384798300 1500353475 7006557825 1239779541 1237529231 我能够这样做,但仅通过插入我想要使用以下代码转换的秒数: da...

0  将通用路径设置为Python中的文件(没有循环)  ( Setting universal path to file in python without for loop ) 
我正在尝试设置我的工作目录,以便它将在所有机器上是通用的 - 但没有循环。我正在使用以下代码,基于此线程:在目录中查找特定路径在Python import os try: ...

5  Python中的群集计算快速JSON序列化(和与泡块的比较)?  ( Fast json serialization and comparison with pickle for cluster computing in py ) 
我有一组数据点,每个数据点由字典描述。每个数据点的处理是独立的,我将每个数据作为单独作业提交给群集。每个数据点都有一个唯一的名称,我的群集提交包装器只需调用脚本,该脚本采用数据点的名称和描述所有数据点的文件。然后,该脚本从文件中访问数据点并执行计算。 由于每个作业必须加载所有点的集合,只能检索要运行的点,我想通过序列...

0  从HTML元素下载图像  ( Download image from html element ) 
我需要下载包含图像的SRC文件。我们可以在下一个选项卡上复制源并粘贴它,以便我们可以下载图像。但是我需要下载图像递归i.e 1000图像。此外,我正在使用的网站包含CAPTCHA的登录。是否有任何方法可以通过dev控制台或任何可能的方式 ...

2  将主列表与CSV行中的单个列表进行比较  ( Comparing master list to individual lists in a csv row ) 
我正在尝试自动化我的教室,我正在击中墙壁,将我的总学生列表与课程和学生的DataFrame进行比较。最终,代码将返回全类类列表。 首先,我的学生总计列表称为 all_kids 。 all_kids=['Kevin', 'Jack', 'Caroline', 'Grace', 'Harry', 'Sam'] df_...

0  将一个3D坐标系旋转到另一个  ( Rotate one 3d coordinate system to another ) 
我在一个坐标系中有一组点,我想将它们旋转到Python中的另一个坐标系。基于此答案我写下以下python函数: def change_of_basis(points, initial, final): ''' rotate points/vectors in a 3D coordinate sys...

0  Python数据类型类型代码综合表或资源  ( Python data type type codes comprehensive table or resource ) 
今天,在其他几个场合,我收到了这样的错误: {TypeError}ufunc subtract cannot use operands with types dtype('<M8[us]') and dtype('O'). 在其他日子里,我想做一些printf类型命令,并处于丢失的损失,该字符用于某些钝数据类...

1  如何用两组重新表达URL?  ( How to regex url with two groups ) 
我收到这个网址: private void playSound(String location) { try { Uri mp3 = Uri.parse("android.resource://" + getPackageName() + "/raw/" + l...

0  服务兼容性意外退出。状态代码是:-9  ( Service chromedriver unexpectedly exited status code was 9 ) 
我对 9988876612 进行了诸多问题,用于使用solemiumings。 $http.get()3 已安装并将其放在与Python文件相同的文件夹中。似乎加载jupyter小区几秒钟的所有建议都被拒绝了以下消息: $http.get()4 其中我使用 $http.get()5 下载它们。在这里我的代码: ...

0  Boketh Plot隐藏HTML网站并仅在Jupyter中显示输出?  ( Boketh plot hide html site and show output only in jupyter ) 
使用散景包,我创建了一个图形可视化,并使用 WaitForMultipleObjects(...)2 输出显示在jupyter中,但也同时使用输出打开浏览器中的新选项卡。我只想将它绘制在Jupyter单元格中,而不将绘图打开作为新的HTML文件。这是不可分割的吗? WaitForMultipleObjects(....

1  根据条件平等查找DataFrame中的匹配对或链条  ( Find matching pairs or chains of persons in dataframe based on equality of cond ) 
我是Python的初学者 - 首先我想为我相当长的问题而道歉,我写的可能非常丑陋的程序来解决我的"问题" 。 问题如下:想象一下房屋的交换。人们可以互相交换他们的房子。 1人从"A" 想要去"B" ,从"B" 的人2想要去"A" 。然后实现了匹配或易货物,并且两者都不再可用于进一步匹配。此外,应涵盖案例,该人1希望从...

9  在Python中线性拟合,在x和y坐标中具有不确定性[关闭]  ( Linear fitting in python with uncertainty in both x and y coordinates ) 
关闭。这个问题不符合堆栈溢出指南。它目前不接受答案。 想要改进这个问题?更新问题,所以它是关于堆栈溢出的主题。 closed 1年前。 ...

0  使用Pandas将对象(数值)转换为DateTime  ( Convert object numeric value to datetime using pandas ) 
我的数据具有时间表,如下所示,如何将其转换为使用Pandas 的日期和时间 ...




© 2021 it.wenda123.org All Rights Reserved. 问答之家 版权所有


Licensed under cc by-sa 3.0 with attribution required.