how to get the hour time?

前端 未结 2 534
深忆病人
深忆病人 2021-01-22 03:22

I\'m working on my python script to get the 12 hours time.

I want to get the 7 hour instead of 07.

self.getControl(4203).setLab         


        
2条回答
  •  天命终不由人
    2021-01-22 04:01

    You can use lstrip to remove a given character from the left side of the result (if it exists):

    hour = time.strftime("%I").lstrip('0')
    print(hour) 
    

提交回复
热议问题