imp*_*ity 4 python python-3.x visual-studio-code f-string vscode-code-runner
我在 VSCode 和 Code Runner 扩展中遇到了这个问题,以下是导致该问题的代码片段:
class init_error(Exception):
def __init__(self, comp="Internals"):
self.component = comp
self.message = f"Error occurred while initiating {self.component}"
def __str__(self):
return self.message
Run Code Online (Sandbox Code Playgroud)
我一开始以为是Python2和Python3之间的编译器搞错了,但在指定#!/usr/bin/env python3并检查是否print("foo")有效后,我相当确定这不是版本问题。我已检查 Code Runner 中的编译器设置为3.7.4 64-bit,因此我尝试通过扩展运行代码Python,并且它有效,所以我相信这是 Code Runner 问题。
很抱歉很长,但最后,f 字符串没有用红色下划线,并且不会出现问题,因此出于某种原因,f 字符串被认为是有效的语法,但不仅仅在代码中运行跑步者延伸。
如何让 Code Runner 接受 f 字符串?
感谢您的帮助。
PS 我认为这无关紧要,但我可以在一个月前发誓它有效。
小智 5
以下是我为使 f-string 在 VS-Code 中工作而采取的步骤的链接



| 归档时间: |
|
| 查看次数: |
5310 次 |
| 最近记录: |