[已解决]python FileNotFoundError: [WinError 3] for getsize(filepath)
问题代码:
def sourceStatic(path, exclude):
# exclude list convert to lower
exclude = list(map(lambda x:x.lower(), exclude))
files_size = 0
files_count = 0
for root, dirs, files in os.walk(path):
for fileName in files:
fname, fileEx = os.path.splitext(fileName)
fileEx = (fileEx[1:]).lower()
if not any(fileEx in item for item in exclude):
print(fileName)
filePath = os.path.join(root,fileName)
fileSize = getsize(filePath)
files_size += fileSize
files_count += 1
# return multiple data as dictionary
ret = {}
ret['files_size'] = size(files_size)
ret['files_size_byte'] = files_size
ret['files_count'] = files_count
print(ret)
return (ret)
报错:
File "C:\Python34\lib\genericpath.py", line 50, in getsize
return os.stat(filename).st_size
FileNotFoundError: [WinError 3] The system cannot find the path specified:
解决:
filePath = u"\\\\?\\" + filePath
fileSize = getsize(filePath)
[已解决]python FileNotFoundError: [WinError 3] for getsize(filepath)的更多相关文章
- python FileNotFoundError: [WinError 2] 系统找不到指定的文件。
D:\Test\TestSWP\Scripts\python.exe D:/Test/SWP/TestSWP/chorme/chorme.pyTraceback (most recent call l ...
- [已解决] Python logging 重复打印日志信息
问题描述 问题代码如下: def get_logger(logger_name): """得到日志对象""" logger = loggin ...
- [Python学习]错误篇二:切换当前工作目录时出错——FileNotFoundError: [WinError 3] 系统找不到指定的路径
REFERENCE:<Head First Python> ID:我的第二篇[Python学习] BIRTHDAY:2019.7.13 EXPERIENCE_SHARING:解决切换当前工 ...
- 已解决】Sublime中运行带input或raw_input的Python代码出错:EOFError: EOF when reading a line(转)
[问题] 在折腾: [已解决]Sublime Text 2中运行Python程序出错:The system cannot find the file specified 的过程中,虽然解决了找不到py ...
- 【已解决】python中文字符乱码(GB2312,GBK,GB18030相关的问题)
http://againinput4.blog.163.com/blog/static/1727994912011111011432810/ [已解决]python中文字符乱码(GB2312,GB ...
- 【Python打包成exe方法】——已解决导入第三方包无法打包的问题
前言 在我们写代码的过程中,我们开发的脚本一般都会用到一些第三方包,可能别人也需要用到我们的脚本,如果我们将我们的xx.py文件发给他,他是不能直接用的,他还需要安装python解释器,甚至还要安 ...
- pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path && FileNotFoundError: [WinError 2] 系统找不到指定的文件。
C:\Users\k\Desktop\test>python test.py Traceback (most recent call last): File , in run_tesseract ...
- 在使用selenium时出现FileNotFoundError: [WinError 2] 系统找不到指定的文件。
今天在使用selenium出现这样的错: Traceback (most recent call last): File "E:\python\lib\site-packages\selen ...
- FileNotFoundError: [WinError 2] 系统找不到指定的文件
用Idle运行Python脚本的时候发现如下错误: Traceback (most recent call last): File "D:\Python\Python36-32\lib\s ...
随机推荐
- odoo action方法
二.动作按钮里面也可以由字段判断: def action_select_sale_order_line(self,cr,uid,ids,date_begin,date_end,context=None ...
- kettle 备注
1. 基本组成 1.1 spoon: 一个可视化的工具,用于编辑kettle ETL的任务脚本 1.2 span: 用以命令行方式执行spoon的转换 1.3 kitchen: 用以命令行方式执行sp ...
- git客户端保存用户名密码
[转载]原文地址:https://blog.csdn.net/qq_26819733/article/details/52735123/ 看图说话,直接在Tortoisegit的设置中,点git-&g ...
- 学python走过的坑 二 element与elements的却别
1.sel = driver.find_elements_by_xpath('//*[@id="nr"]')# 搜索结果显示条数2.sel = driver.find_elemen ...
- android学习笔记--检测是否为wifi环境
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); // 获取 ...
- cAdvisor+Prometheus+Grafana监控docker
cAdvisor+Prometheus+Grafana监控docker 一.cAdvisor(需要监控的主机都要安装) 官方地址:https://github.com/google/cadvisor ...
- linux下利用nohup后台运行jar文件包程序
Linux 运行jar包命令如下: 方式一: java -jar XXX.jar 特点:当前ssh窗口被锁定,可按CTRL + C打断程序运行,或直接关闭窗口,程序退出 那如何让窗口不锁定? 方式二 ...
- springboot~maven制作底层公用库
把一些公用方法,类型抽象到一个项目里,让其它项目依赖它,这种设计是一种解耦的体现,其实像springboot就是我们的一种依赖,他里面有很多子模块,用到哪个就添加哪个依赖即可,像redis,mongo ...
- 前端知识复习: JS选中变色
前端知识复习:JS选中变色 上篇文章 :前端知识复习:Html DIV 图文混排(文字放在图片下边) Js选中图片效果 <!DOCTYPE html> <html xmlns=&qu ...
- PHP信号管理
PHP信号管理 SIGHUP 终止进程 终端线路挂断 SIGINT 终止进程 中断进程 SIGQUIT 建立CORE文件终止进程,并且生成core文件 SIG ...