Pycharm有一个非常有用的热键:代码选择 -> cmd+alt+T(macOS)-> 选择您想要放置所选代码的构造(if、while、try 等)。vscode中有类似的东西吗?或者可能需要某种扩展?
哪些内容不能输入Snippets: Surround with snippet
在 Mac OS 上的 vscode 中,有一个有用的热键⌘ cmd+F2它替换了所有提及的所选变量的名称。一个缺点是它会在整个文件中执行此操作。在 paycharm 中,这种替换只能在块、函数等内部完成。 vscode中有类似的东西吗?
vscode 中 ipython 的更多问题。我打开了一个以前在 pycharm 中使用过的项目,运行脚本并在控制台中收到消息
ipython --no-autoindent --InteractiveShellApp.exec_lines="%load_ext autoreload" --InteractiveShellApp.exec_lines="%autoreload 2"
.venv➜ my ipython --no-autoindent --InteractiveShellApp.exec_lines="%load_ext autoreload" --InteractiveShellApp.exec_lines="%autoreload
2"
zsh: command not found: ipython
.venv➜ my git:(b) ✗ %run "/Users/4izhyk/Documents/Python/myPoker/main.py"
fg: job not found: run
我不明白这意味着什么以及他们想从我这里得到什么。帮我弄清楚或者更好地告诉我如何在这个 vscode 中使用 Python,以便它尽可能接近 pycharm、一些扩展或其他东西,否则我已经厌倦了这个 vscode,但 pycharm 加载很长一段时间,他们建议 vscode,我决定尝试一下,我很痛苦。
终于准备从pycharm切换到vscode了。我正在努力让它尽可能无痛。为此,我安装了 ipython 扩展,它在与 pycharm 最相似的窗口中运行代码。
我在启动的时候遇到了一个问题:
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
handler_format = logging.Formatter(
fmt='[%(asctime)s: %(levelname)s] %(message)s')
handler.setFormatter(handler_format)
logger.addHandler(handler)
logger.debug('debug information')
控制台显示如下:
In [1]: %run "/Python/project/one.py"
[2024-11-12 06:42:21,680: DEBUG] debug information
这里没有问题,但是如果再次运行代码,输出将如下:
In [2]: %run "/Python/project/one.py"
[2024-11-12 06:44:20,336: DEBUG] debug information
[2024-11-12 06:44:20,336: DEBUG] debug information
输出似乎是重复的。仅当将日志输出到控制台时才会发生这种情况。我在网上看了很多资料,都没有出现这样的问题。