问题
I need to insert into mongo db some BC dates but I cant create datetime with negative value like datetime.datetime(-2000, 2, 1)
, but in mongodb it is possible to do with IsoDate, so how can i create negative dates in python?
I'm currently using python 2.7, and i do it on purpouse, for the project.
回答1:
Python 2.7's datetime library can only handle AD dates. If you need to go back further than that you will have to look at other libraries such as the Time
class in Astropy or date
in datautil.
来源:https://stackoverflow.com/questions/32161570/how-to-create-negative-datetime-in-python-2-7