在Python中将阿拉伯字符(东方阿拉伯数字)转换为阿拉伯数字
发布时间:2020-12-20 11:45:49 所属栏目:Python 来源:网络整理
导读:我们的一些客户提交的时间戳如2015-10-03 19:01:43 谷歌翻译为“03/10/2015 19:01:43”.链接 here. 我怎样才能在Python中实现相同的目标? 解决方法 要将时间字符串转换为datetime对象(Python 3): import re from datetime import datetime datetime(*map(i
我们的一些客户提交的时间戳如2015-10-03 19:01:43
谷歌翻译为“03/10/2015 19:01:43”.链接 here. 我怎样才能在Python中实现相同的目标? 解决方法
要将时间字符串转换为datetime对象(Python 3):
>>> import re >>> from datetime import datetime >>> datetime(*map(int,re.findall(r'd+',' ????-??-?? ??:??:??'))) datetime.datetime(2015,10,3,19,1,43) >>> str(_) '2015-10-03 19:01:43' 如果您只需要数字: >>> list(map(int,' ????-??-?? ??:??:??'))) [2015,43] (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |