让 py 知道 (input1) == (input2)

Let py know that (input1) == (input2)

我想让我的脚本停止,请先询问我什么时候停止:

length = input("how many times " + str(num1) + str(" do you want to see?")) (例如,我说“3”,长度应该是 3) 然后我想“询问”长度是否与它应该完成时必须的位置相同: if length == times(时间是我的脚本是ATM的地方) 这行不通,但如果我将时间设置为一个数字,它就可以工作…… 即使我同时打印它们 (print (times, length)),它在我的控制台中显示相同的 (3, 3),但它什么也没做……这是我的脚本:

length = input("how many times " + str(num1) + str(" do you want to see?"))
 print("starting!")
 time.sleep(2)
 ORnum1 = num1
 times = 1
 while CalcMeth == "repeat":
  if C == "Yes":
     print(times, "times", ORnum1, "=", num1)
     num1 = num1 + ORnum1
     if length == times:
       C = "no"
       print("Reached End, stopping.")
     else:
       time.sleep(num2)
     times = times + 1
  elif C == "no":
   time.sleep(2)
   print ("stopped!")
   sys.exit()
if length == times: 

此处您的代码长度为 str,时间为整数。

length = int(input("how many times " + str(num1) +" do you want to see?))