The problem with our first call to listdir was
我们马上在第二次调用时修正了这个失误。
Since we just created it. The problem with our first call to listdir was
我们马上在第二次调用时修正了这个失误。
The os module's listdir call provides yet another way to collect filenames in a Python list.
os模块的listdir调用提供了另一方法,它会将名字收集成Python列表。
Since we just created it. The problem with our first call to listdir wasthat we forgot to give the name of the directory we want to list.
第一次调用 listdir 调用时出现的问题是因为我们没有传递要列目录的路径名。
Next, we create a subdirectory in our temporary directory, after which we will use the listdir method to confirm that the directory is indeed empty
第一次调用 listdir 调用时出现的问题是因为我们没有传递要列目录的路径名。
For convenient processing, scripts often need to split glob results into base files or expand listdir results into full paths.
为方便处理,脚本通常需要将glob的结果分割成基本文件名,或将listdir的结果扩展到完整路径。
In the last example, I pointed out that glob returns names with directory paths, whereas listdir gives raw base filenames.
我在上例中指出,glob返回带目录路径的名字,而listdir给出的是原始的基本文件名。