ListFiles

摘要

Returns a list of files in the current workspace based on a query string. Specifying search conditions can be used to limit the results.

讨论

必须先设置工作空间环境,之后才能使用多个列表函数,这些列表函数包括 ListDatasetsListFeatureClassesListFilesListRastersListTablesListWorkspaces

语法

ListFiles ({wild_card})
参数说明数据类型
wild_card

通配符可限制返回的结果。如果未指定任何通配符,则会返回所有值。

String
返回值
数据类型说明
String

A list of files.

代码示例

ListFiles example

Copy a list of CSV files to dBASE format.

import arcpy
from arcpy import env
import os

env.workspace = "c:/temp"

# Copy each file with a .csv extension to a dBASE file
#
for file in arcpy.ListFiles("*.csv"):
    # Use splitext to set the output table name
    #
    dbfFile = os.path.splitext(file)[0] + ".dbf"
    arcpy.CopyRows_management(file, dbfFile)

相关主题


7/10/2012