What do you want to save?
Add Code snippet
New code examples
-
Python 2021-10-22 06:48:09
python find end of month
import calendar from datetime import datetime year = 2020 month = 1 rng = calendar.monthrange(year, month) # (2, 31) last_day = datetime(year, month, rng[1]) # calendar.monthrange returns tuple in the format of # (<day of week>, <last day>... Add solution -
Python 2021-10-21 16:10:12
how to convert time from one timezone to another in python
from datetime import datetime from pytz import timezone format = "%Y-%m-%d %H:%M:%S %Z%z" # Current time in UTC now_utc = datetime.now(timezone('UTC')) print(now_utc.strftime(format)) # Convert to Asia/Kolkata time zone now_asia = now_utc.astime... Add solution -
Python 2021-10-18 18:52:12
https://docs.djangoproject.com/en/dev/topics/signing/#django.core.signing.Signer
from datetime import timedelta from django.core.signing import TimestampSigner signer = TimestampSigner() value = signer.sign('hello') value signer.unsign(value) signer.unsign(value, max_age=10) signer.unsign(value, max_age=20) signer.unsign(value, max... Add solution