python - 为什么 tempfile 和 os.chdir() 会抛出 RecursionError?
问题描述
import os, tempfile
with tempfile.TemporaryDirectory() as tempdir:
os.chdir(tempdir)
为什么这会引发 RecursionError?首先,这段代码是如何递归的?我将如何将工作目录更改为临时目录?
解决方案
实际的错误是这样的:The process cannot access the file because it is being used by another process
tempdir
在删除之前需要更改工作目录。
推荐阅读
- react-native - 如何在排毒测试中从 RNN 中识别导航选项卡按钮
- python - 使用“python -c”控制台命令模式实现for循环
- r - 量词可以用于R中的正则表达式替换吗?
- c - C - 打印文本拆分为多行的奇怪问题?
- python - 将 One-Hot 编码矩阵编码为单个数组整数编码
- vue.js - Vue JS 道具不足
- node.js - 避免 req.flash 删除中间件上的数据
- postgresql - Postge中是否有默认密码强度规则/约束之类的东西?
- python - Python - comtypes(工作)与 pywin32(不工作) - 使用 python 创建 Outlook 规则
- arrays - 当 ArrayList 包含 <= 1 项且仅在 PS 5 中时,为什么我的 ArrayList 会抛出“PSCustomObject 不包含 'foreach' 的方法”错误?