python - datetime.datetime.utcnow() why no tzinfo? - Stack Overflow

python - datetime.datetime.utcnow() why no tzinfo? - Stack Overflow

瀏覽:460
日期:2025-04-25
That means it is timezone naive, so you can't use it with datetime.astimezone you can give it a timezone like this import pytz # 3rd party u=datetime.utcnow() u=u.replace(tzinfo=pytz.utc) now you can change timezones print datetime.astimezone(u, pytz.time...看更多