简体   繁体   English

if 语句在运行但不空闲时给出错误

[英]if statement giving errors when ran but not in idle

I making a if statement for my program and when it runs it gives an error.我为我的程序做了一个 if 语句,当它运行时它给出了一个错误。 This is my code:这是我的代码:

if num1 = num2:
    print('Equal')

when you compare in python its == not =当您在 python 中进行比较时,它 == 不是 =

Basically, you've mixed up thw two operaters.基本上,您已经混淆了两个操作员。 = is used for assignment(such as x = 5). = 用于赋值(如 x = 5)。 == is used to compare two values(like comparing x == y). == 用于比较两个值(如比较 x == y)。

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

相关问题 从IDLE运行时,同一个程序运行良好,但直接运行时,同一个程序运行不正常 - Same Program Runs Fine when ran from IDLE but not when ran directly django.setup() 给我 ModuleNotFoundError: 当在 pycharm 中运行时 - django.setup() giving me ModuleNotFoundError: when ran in pycharm pyttsx3.init() 将导致程序崩溃,并给出诸如“用完输入”之类的错误。 我该如何解决? - pyttsx3.init() will cause the program to crash, giving errors like 'ran out of input'. How do I fix this? Python 多线程 - 使用 While 语句运行时未释放内存 - Python multithreading - memory not released when ran using While statement 我启动Python shell时的错误,是我一周前运行的脚本中的错误 - Errors when I start the Python shell, errors from a script I ran a week ago Python IDLE上的缩进错误 - Indention Errors on Python IDLE 123 到 321 问题在迭代时给出错误 - 123 to 321 problem giving errors when iterating Discord API 在尝试导入时出错 - Discord API giving errors when trying to import it 通过IDLE和双击脚本运行Python脚本时,sys模块提供不同的输出 - sys module giving different output when running Python script through IDLE and by double-clicking the script 在python脚本中运行时,如何将sql查询的输出(甚至错误/警告)存储在文件中? - How to store the output(even errors/warning) of sql queries in a file when ran in python script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM