Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么我的Python代码在VisualStudio代码中没有正确运行,但在空闲时运行良好?_Python_Python 3.x_Visual Studio Code_Python Idle - Fatal编程技术网

为什么我的Python代码在VisualStudio代码中没有正确运行,但在空闲时运行良好?

为什么我的Python代码在VisualStudio代码中没有正确运行,但在空闲时运行良好?,python,python-3.x,visual-studio-code,python-idle,Python,Python 3.x,Visual Studio Code,Python Idle,我目前正在学习Python,遇到了一个非常奇怪的问题(至少对我来说)。当我键入此代码时: def search4vowels(word): """Display any vowels found in a supplied word.""" vowels = set('aeiou') found = vowels.intersection(set(word)) return bool(found) 在I

我目前正在学习Python,遇到了一个非常奇怪的问题(至少对我来说)。当我键入此代码时:

def search4vowels(word):
    """Display any vowels found in a supplied word."""
    vowels = set('aeiou')
    found = vowels.intersection(set(word))
    return bool(found)
在IDLE编辑窗口中,使用IDLE运行它,一切正常,我需要在提示符处键入我的函数才能启动

但是,当我在VisualStudio代码中编写相同的代码并使用运行 终端中的Python文件选项我得到的是:

我还尝试了代码运行程序扩展,这给了我一个空白的输出页面,无法输入函数

例如
search4元音('galaxy')

我期望的输出应该是:
True
(因为元音会出现在单词中,因此为True)


但是,什么也没有发生。

您正在定义函数
search4元音()
,但Visual Studio代码不知道如何运行它

尝试在代码中添加以下内容:

def search4vowels(word):
    """Display any vowels found in a supplied word."""
    vowels = set('aeiou')
    found = vowels.intersection(set(word))
    return bool(found)

# This tells your code to run the function search4vowels():
if __name__ == '__main__':
    print(search4vowels('your word'))

这里是关于单词
“\uuuuu main\uuuuuuu”

谢谢,这就解决了它