You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用psutil.disk_usage报错:argument 1 (impossible<bad format char>)求助

Windows下psutil.disk_usage报错解决方案

路径格式修正

Windows系统的磁盘路径格式和类Unix系统不同,需使用符合Windows规范的路径写法:

  • 转义反斜杠:psutil.disk_usage('C:\\')
  • 原始字符串:psutil.disk_usage(r'C:\')
  • 正斜杠替代:psutil.disk_usage('C:/')

升级psutil版本

Python 3.12属于较新版本,旧版psutil可能存在兼容性问题,执行以下命令更新到最新版:

pip install --upgrade psutil

测试验证

更新后运行以下代码确认问题修复:

import psutil
print(psutil.disk_usage(r'C:\'))

内容的提问来源于stack exchange,提问作者Geo48

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 12:35:53