python - AttributeError:“unicode”对象没有属性“strftime”
问题描述
我有以下代码:
import arcpy, os
from arcpy.sa import *
arcpy.env.overwriteOutput = True
fc = r'E:\dada proj\DRAW OBJECTS\VIPPoints.mdb\Allfeat'
# Point feature class, needs to be in a file geodatabase (for the where clause to work)
output_folder = r'C:\GIS\data\testdata' # Where the rasters will be saved
date_field = 'date_' # field holding the dates (date type, not string)
value_fields = ['CO', 'O3', 'NO2'] # field with the values to interpolate
all_dates = list({i[0] for i in arcpy.da.SearchCursor(fc, date_field)}) # List all unique dates
for date in all_dates:
# Create a feature layer of each unique date
where = "{0}=date '{1}'".format(arcpy.AddFieldDelimiters(datasource=fc, field=date_field),
date.strftime('%Y-%m-%d'))
arcpy.MakeFeatureLayer_management(in_features=fc, out_layer='lyr', where_clause=where)
# For each field interpolate. This is untested since I dont have spatial analyst
for fieldname in value_fields:
outIDW = Idw(in_point_features='lyr', z_field=fieldname,
cell_size=10) # , {power}, {search_radius}, {in_barrier_polyline_features})
outIDW.save(os.path.join(output_folder, '{0}_{1}.tif'.format(fieldname, date.strftime('%Y%m%d'))))
当我运行它时,我得到了错误
AttributeError: 'unicode' object has no attribute 'strftime'
我的日期在表格和格式中:yyyy/mm/dd 感谢任何解决错误的建议
解决方案
推荐阅读
- c# - 您可以向 List() 添加索引以加快搜索速度吗
- vue.js - 在对象中推送唯一数组 | Vuejs
- java - 如何在用户进入活动特定时间后显示 Ad Mob 添加
- python - keras model.get_weight 未返回预期尺寸的结果
- java - 正则表达式模式从字符串中提取版本号
- html - 我需要帮助创建 4 列,并在其下方有一排有两列
- javascript - 从 for 循环创建一个数组数组
- python - sqlite 数据库中的 Flask Migration 集成
- angular - 使用 Angular 在数据库中以不同的名称提交相同的文件
- cross-compiling - How to fix "Section .vectors overlaps section .data " | Adding ATmega1281 Support to Compiler