python-3.x - 让 PyC​​harm 将字符串识别为路径

标签 python-3.x pycharm code-completion

我正在使用 Python 3.4。

当我使用 IDLE 并开始输入时,例如,
my_main_folder = "C:/Us"
在编辑器窗口中,然后按 Ctrl + Space , IDLE 为我提供了 C: 的所有子文件夹,如果我按 Tab ,字符串补全到"C:/Users" .

这意味着 IDLE(或 Python Shell)能够将字符串识别为路径。

如何让 PyC​​harm(社区版)做到这一点?

最佳答案

Its not able in Community Edition Pycharm. But it can be done in Professional Edition Pycharm. I would suggest you to move to Professional Edition.

Does PyCharm have autocomplete file path?


但是,在社区版中有一个解决方法。Place caret in such place and press Alt+Enter -- see if you will have "Inject language or reference" option in appeared menu. If it's present -- use it and choose "File Reference" there.
  • 注意 1:如果字符串为空或少于 2 个字符,此选项可能不可用
  • 注意 2:这是临时注入(inject) - AFAIK 它将在 IDE 重新启动后丢失(如果需要,您需要再次执行此操作)
  • Otherwise: select desired file in Project View panel and use "Copy Reference" -- it will copy a file path relative to the project root -- you may only need to add leading "/"... https://intellij-support.jetbrains.com/hc/en-us/community/posts/206574619-Autocompleting-relative-paths

    关于python-3.x - 让 PyC​​harm 将字符串识别为路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42348541/

    相关文章:

    python - 为什么 TimedRotatingFileHandler 不删除旧文件?

    python-3.x - 如何遍历数组对每个像素应用阈值

    python - Pycharm - 编辑安装包

    version-control - PyCharm 中用于 Jupyter 笔记本的 VCS

    javascript - 如何在 Sublime 3 中为 tern-js 设置跳转到方法定义键绑定(bind)

    c# - 当从 F# 使用 AvalonEdit 时,CompletionWindow(CodeCompletion 命名空间)中的白线而不是文字

    python-3.x - 在没有pylint错误的情况下捕获所有异常

    python-3.x - 如何在 Tensorflow 中拆分 LSTM 的训练数据和测试数据以进行时间序列预测

    intellij-idea - 如何在Pycharm中使用 "Replace in selection"

    xcode - 代码完成在基于 swift 的 Cocoa Touch Framework 中不起作用