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

如何设置项目工具窗口随os.chdir切换显示当前目录?

实现os.chdir切换目录后自动更新项目工具窗口的设置方法

针对主流Python IDE,分别提供对应设置步骤:

PyCharm

  • 打开设置(路径:File > Settings,快捷键Ctrl+Alt+S)
  • 进入Appearance & Behavior > System Settings选项页
  • 在Synchronization板块,勾选以下两项:
    • Synchronize files on frame activation
    • Synchronize files automatically
  • 若切换目录后仍未自动刷新,可按Ctrl+F5手动强制刷新项目窗口

VS Code

  • 打开设置(路径:File > Preferences > Settings,快捷键Ctrl+,)
  • 在搜索栏输入files.autoRefresh,勾选该选项开启自动刷新
  • 若外部目录未显示,检查files.exclude设置,移除对目标目录的排除规则(如果存在)
  • 手动刷新可点击资源管理器的刷新按钮,或按Ctrl+R

Spyder

  • Spyder默认支持该功能,执行os.chdir()或cd命令后,Files标签会自动同步当前工作目录
  • 若出现同步异常,可点击Files标签右上角的刷新按钮,或进入Tools > Preferences > Files,确认Automatically synchronize the Files pane with the current working directory选项已勾选

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 17:36:23