我试图制作一个Python时钟,但无法使其循环

时间:2020-08-03 19:29:27

标签: python clock

我试图用Python制作一个Clock,但是我无法使其与“ for loop”循环,如何使其工作,因此它将循环结尾的ASCII?

text = " The Date and Time Is : "

在这里,我指示python使用datetime模块获取本地时间

import datetime 
x = datetime.datetime.now()
Year = (x.strftime("%Y"))




import datetime 
x = datetime.datetime.now()
Month = (x.strftime("%B"))




import datetime 
x = datetime.datetime.now()


Day = (x.strftime("%A"))


NumDay = (x.strftime ("%d"))




import datetime 
x = datetime.datetime.now()
Time = (x.strftime("%X"))

Pm = (x.strftime("%p"))

full_time = Time+ " " +Pm






now = "Today is : " + str(Day) + " , " + str(NumDay) + " " + str(Month) + " " + str(Year) + " , " + str(full_time)

这时,我考虑过将var的总和变成类似ASCII。

import pyfiglet 


result=pyfiglet.figlet_format(now, font = "digital") 
print(result)

在这里,我认为for循环可能会解决循环问题,因此尽管将其与无穷大进行比较

import math 
nr = math .inf 

if nr  >1000000000 : 
    print("This number is indeed infinite ")

这是个大问题,for循环根本不起作用

for int(result) in range(1,nr) 
print(result)

1 个答案:

答案 0 :(得分:0)

#感谢Jarmod,我发现一个while循环解决了它!

import math 
nr = math .inf 

if nr  >1000000000 : 
    print("This number is indeed infinite ")

count = 0 
while count < nr :
  print(result)