# coding=gbk import csv import arcpy def main(): # 读取 # csv_path=r"E:2 learningcoursearcpy进阶arcpy4 文本读写csv est.csv" # csv_file=open(csv_path,'r') # csv_reader=csv.reader(csv_file) # csv_reader.next() # for line in csv_reader: # print line[1].decode('gbk') # csv_file.close() # 写入 # csv_path_out=r"E:2 learningcoursearcpy进阶arcpy4 文本读写csvout.csv" # csv_file_out=open(csv_path_out,'wb') # csv_writer=csv.writer(csv_file_out) # title=['序号','影片名称','实时票房(万)','票房占比','累计票房(万)','排片占比','上映天数'] # csv_writer.writerow(title) # csv_writer.writerows(csv_reader) # csv_file.close() # csv_file_out.close() # 字段属性写入csv fc_path=r'E:2 learningcoursearcpy进阶arcpy 基础数据访问data.mdb est' csv_path_out=r"E:2 learningcoursearcpy进阶arcpy4 文本读写csvfields.csv" csv_file_out=open(csv_path_out,'wb') csv_writer=csv.writer(csv_file_out) title=['字段名','别名','类型','长度','精度','小数位数'] csv_writer.writerow(title) fields=arcpy.ListFields(fc_path) for field in fields: csv_writer.writerow([ field.name.encode('gbk'), field.aliasName.encode('gbk'), field.type.encode('gbk'), field.length, field.precision, field.scale ]) csv_file_out.close() if __name__ == '__main__': main()