【问题标题】:I am unable to get any sort of output我无法获得任何类型的输出
【发布时间】:2021-11-23 06:54:36
【问题描述】:

这是我的 python 代码:我最后得到的唯一输出是 "True" 为什么我没有收到其他人的输出?请帮忙。 我在 Visual Studio 代码上使用 jupyter notebook。内核:Python 3.9 64 位

# RELATIONAL OPERATORS
num1 = 10
num2 = 0
num3 = 10
str1 = "good"
str2 = "life"

# Equals to
num1 == num2
str1 == str2

# Not equal to
num1 != num2
str1 != str2
num1 != num3

# Greater Than
num1 > num2
str1 > str2

# Less Than
num1 < num3
str2 < str1

# Greater than or equal to
num1 >= num2
num2 >= num3
str1 >= str2

#Less then or equal to
num1 <= num2
num2 <= num3
str1 <= str2

【问题讨论】:

  • 你没有用print,把这些表达式写在print()
  • 对于极端的初学者来说,这可能值得注意,这取决于源代码的来源/您阅读的教程,will show output in the REPL for every statement 因为那是 REPL 所做的。 REPL 以&gt;&gt;&gt; 开头。在一个完整的程序中,你需要告诉 Python 向你展示输出。
  • 啊,是的,它成功了!谢谢!

标签: python visual-studio-code jupyter-notebook relational-operators


【解决方案1】:

您必须将每个语句包装在 print() 中

num1 = 10
num2 = 0
num3 = 10
str1 = "good"
str2 = "life"

print(num1 == num2)
print(str1 == str2)
# so on and so forth

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-13
    • 2019-08-29
    • 2014-10-18
    • 2021-09-12
    • 1970-01-01
    • 2011-07-12
    • 2016-07-02
    • 1970-01-01
    相关资源
    最近更新 更多