【问题标题】:Clearing the console in python在python中清除控制台
【发布时间】:2022-06-25 19:33:53
【问题描述】:

我想通过在“istep”或“ito”中输入“0”来清除控制台,但仅当我在“ito”中输入“0”时才有效...谢谢!

import os

while True:
   ifrom=int(input("From: "))
   istep=int(input("Step: "))
   ito=int(input("To: "))

   if istep or ito==0:
       os.system('cls')

【问题讨论】:

    标签: python python-3.x


    【解决方案1】:

    您需要在两种情况下都使用== 运算符:

    if istep == 0 or ito==0:
      os.system('cls')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-08
      • 1970-01-01
      • 1970-01-01
      • 2015-11-21
      • 1970-01-01
      相关资源
      最近更新 更多