我正在为下载文件夹编写排序器。我收到此错误,我尝试更改权限:
chmod: Unable to change file mode on Users: Operation not permitted
import os
from_dir = os.path.dirname('/Users/user/Downloads/')
working_dir = os.walk(from_dir)
to_dir = os.path.dirname('/User/user/Downloads/New Folder/')
def move(folder):
for roots, dirs, files in folder:
for file in files:
src_folder = from_dir + '/' + file
to_folder = to_dir + '/' + file
if not os.path.exists(to_dir):
os.makedirs(to_dir)
os.rename(src_folder, to_folder)
move(working_dir)
Run Code Online (Sandbox Code Playgroud)
也许还有另一种方法可以在不触及根文件夹的情况下编写此代码?
完整错误:
Traceback (most recent call last):
File "/Users/beknazarnurbek/Documents/PycharmProjects/Move Files/move.py", line 19, in <module>
move(working_dir)
File "/Users/beknazarnurbek/Documents/PycharmProjects/Move Files/move.py", line 14, in …Run Code Online (Sandbox Code Playgroud) 代码在我的本地机器上运行良好,没有出现错误。但是当我推送到 GitHub 时,构建失败了。
这是我的工作流文件块:
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
- name: Install `rust-src` Rustup Component
run: rustup component add rust-src
- name: Run `cargo check`
uses: actions-rs/cargo@v1
with:
command: check
Run Code Online (Sandbox Code Playgroud)
这是错误。
error: failed to read `/usr/share/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/Cargo.toml`
21
##[error]failed to read `/usr/share/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/Cargo.toml`
22
Caused by:
23
No such file or directory (os error 2)
24
##[error]The process '/usr/share/rust/.cargo/bin/cargo' failed with exit code 101 …Run Code Online (Sandbox Code Playgroud)