其他分享
首页 > 其他分享> > TypeError: can only concatenate str (not “list“) to str

TypeError: can only concatenate str (not “list“) to str

作者:互联网

问题分析:字符串只能和字符串连接,不能与数组连接。

#获取pdf文件名称并截取图片
for dirs in RP_DIRS_ARR:
    for root,dirs,files in os.walk(FEILE_ADDR+NOW_DAY+'\\'+RP_DIRS_ARR):
        pdf_arr = []
        for str in files:
            if(str[-3:]=='pdf'):
                pdf_arr.append(str)
    break

问题解决:第一个for循环的dirs是字符串,RP_DIRS_ARR是数组,第二for循环连接的数组换成字符串。

标签:concatenate,DIRS,ARR,RP,only,str,pdf,dirs
来源: https://blog.csdn.net/qq_38335295/article/details/123184349