gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 22:29:39 25 4
gpt4 key购买 nike

我正在使用 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/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com