我正在使用 Python 3.4。
当我使用 IDLE 并开始输入时,例如,my_main_folder = "C:/Us"
在编辑器窗口中,然后按 Ctrl + Space
, IDLE 为我提供了 C:
的所有子文件夹,如果我按 Tab
,字符串补全到"C:/Users"
.
这意味着 IDLE(或 Python Shell)能够将字符串识别为路径。
如何让 PyCharm(社区版)做到这一点?
最佳答案
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.
但是,在社区版中有一个解决方法。
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.
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 - 让 PyCharm 将字符串识别为路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42348541/