Test.py:
def test():
print("Hello World")
test()
当我使用解释器(ctrl+shift+p > Python:选择解释器 > 目标解释器)运行它时,它起作用了。
如果我随后尝试运行 repl (ctrl+shift+p > Python: Start REPL),我会看到 repl 在终端中启动:
PS C:\Development\personal\python\GettingStarted> & c:/Development/personal/python/GettingStarted/.venv/Scripts/python.exe
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
但是,如果我尝试在 repl 中执行定义的方法,我会得到一个未定义的错误:
>>> test()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'test' is not defined
Smart猫小萌
相关分类