简体   繁体   English

python3中的VSCODE中没有终端输出

[英]no terminal output in VSCODE in python3

I haved defined a function to check PIG LATIN function runs on anaconda navigator but no terminal output in vs code.我已经定义了一个函数来检查 PIG LATIN 函数在 anaconda navigator 上运行但在 vs 代码中没有终端输出。

def pig_latin(word):

    first_letter = word[0]

    if first_letter in 'aeiou':
        pig_word = word + 'ay'
    else:
        pig_word =  word[1:] + first_letter + 'ay'  
    return pig_word

To get the output in the terminal, you have to call the print() function.要在终端中获得输出,您必须调用print()函数。 At the last line of your code, call the pig_latin function with print() function, something like:在代码的最后一行,使用print()函数调用pig_latin函数,例如:

def pig_latin(word):

    first_letter = word[0]

    if first_letter in 'aeiou':
        pig_word = word + 'ay'
    else:
        pig_word =  word[1:] + first_letter + 'ay'  
    return pig_word
print(pig_latin('hello'))

If you're using Python 2.x, you can print to console by calling print without the parentheses:如果您使用的是 Python 2.x,则可以通过调用不带括号的 print 来打印到控制台:
print pig_latin('hello')

And make sure that the file is saved with a .py extension and run it by calling python3 fileName.py并确保文件以.py扩展名保存并通过调用python3 fileName.py运行它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM