Python Date Conversion. How to convert arabic date string into date or datetime object python

前端 未结 5 2011
梦谈多话
梦谈多话 2021-01-23 06:40

I have to convert this date into normal date string/object.

١٩٩٤-٠٤-١١ to 11-04-1994.

5条回答
  •  遇见更好的自我
    2021-01-23 07:21

    To create a date object from the arabic date string:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    from datetime import date
    
    d = date(*map(int, u"١٩٩٤-٠٤-١١".split('-')))
    # -> datetime.date(1994, 4, 11)
    

提交回复
热议问题