python - 尝试重命名 Program Files (x86) 中的每个文件时出现 OSError
问题描述
我是 python 的初学者,想搞砸一点,由于当前爆发了冠状病毒,我认为尝试制作一个脚本将它可以重命名的每个文件(避免 Windows 错误)重命名为冠状病毒会很有趣,但是当试图重命名程序文件中的所有内容我得到了一个奇怪的 OSError。到目前为止我从未遇到过这个问题,我不知道如何解决它。(如果可以的话)
import os
PRF = r"C:\Program Files (x86)"
for root in os.walk(PRF)
os.rename(str(root) , "Coronavirus!")
它给出了这个错误:
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: "('C:\\\\\\\\Program Files (x86)', ['Common Files', 'Internet Explorer', 'Microsoft.NET', 'Reference Assemblies', 'Windows Defender', 'Windows Mail', 'Windows Media Player', 'Windows Multimedia Platform', 'Windows NT', 'Windows Photo Viewer', 'Windows Portable Devices', 'Windows Sidebar', 'WindowsPowerShell'], ['desktop.ini'])" -> 'Coronavirus!'
另外,如果您需要知道我正在虚拟机上执行此操作
解决方案
推荐阅读
- http - 在非服务器上启用 HTTP 选项
- amazon-web-services - S3::PutObject 返回 403 - Aws Php
- python-2.7 - 2021年如何在Python 2.7上安装pip
- swift - 如何在 swiftUI 应用程序中在后台运行核心数据任务?
- rust - 将方法指针向量传递给另一个方法以执行
- node.js - 如何让“foreach(file)”函数在另一个文本文件中创建一个列表?
- amazon-web-services - aws ecs docker 容器无法访问互联网
- reactjs - 在暗/亮模式之间切换 Material UI
- html - 如何让元素慢慢失去动画?
- numbers - pari软件quadray中mod是什么意思