Home > Software engineering >  How to bring a leading zero from excel and typed out with pyautogui?
How to bring a leading zero from excel and typed out with pyautogui?

Time:03-04

I need to bring a date from a spreadsheet and paste it into another program but the date format is dd/mm/yy and there needs to be a leading zero if it's not oct, nov, or dec. Any ideas? Below is the code I am using. It brings the number is but drops the leading zero I really need.

pyautogui.typewrite(str(excel_data['Check Date'][count]))

CodePudding user response:

Is this all you need?

date = str(excel_data['Check Date'][count])
date = f'{date[:3]}0{date[3:]}' if len(date) < 8 else date
pyautogui.typewrite(date)
  • Related