main.py
814 Bytes
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
from datetime import datetime
from dateutil.relativedelta import *
def add_one_month(date, i):
# Add one month to the date using timedelta
next_month = date + relativedelta(months=+i)
print(next_month)
# Roll back to the last day of the previous month
new_date = next_month.replace(day=1)
print(new_date)
return new_date
def yang():
print('nihao')
if __name__ == '__main__':
print_hi('PyCharm')
yang()
# for i in range(60):
# print('i===', i)
# Example usage
date = datetime(2021, 5, 1)
new_date = add_one_month(date, 1)
print('new_date', new_date) # Output: 2022-04-30 00:00:00