python输出AttributeError: 'str' object has no attribute 'strftime',如何解决这问题?
data=pd.read_excel('E:6月1日-10日考勤表.xls',index_col='姓名')SJ=data.loc['刘三',('时间')]SJ=SJ.w...
data = pd.read_excel('E:6月1日-10日考勤表.xls', index_col='姓名')
SJ = data.loc['刘三',('时间')]
SJ = SJ.where(SJ.notnull(),0)
a = -1
for num in range(a,9):
a = a + 1
SJ2 = SJ[a]
SJ2 = str(SJ2)
SJ3 = SJ2[:5]
d3 = SJ3.strftime('%H:%M')
print('d3:', d3)
结果输出是
Traceback (most recent call last):
File "E:/PY文件/hello12.py", line 20, in <module>
d3 = SJ3.strftime('%H:%M') # 格式化字符串输出
AttributeError: 'str' object has no attribute 'strftime' 展开
SJ = data.loc['刘三',('时间')]
SJ = SJ.where(SJ.notnull(),0)
a = -1
for num in range(a,9):
a = a + 1
SJ2 = SJ[a]
SJ2 = str(SJ2)
SJ3 = SJ2[:5]
d3 = SJ3.strftime('%H:%M')
print('d3:', d3)
结果输出是
Traceback (most recent call last):
File "E:/PY文件/hello12.py", line 20, in <module>
d3 = SJ3.strftime('%H:%M') # 格式化字符串输出
AttributeError: 'str' object has no attribute 'strftime' 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询