解决方法
>>> from datetime import datetime >>> datetime.strptime('02/11/2010','%d/%m/%Y').strftime('%Y-%m-%d') '2010-11-02'
或更多的黑客方式(不检查值的有效性):
>>> '-'.join('02/11/2010'.split('/')[::-1]) '2010-11-02' >>> '-'.join(reversed('02/11/2010'.split('/'))) '2010-11-02'