python-3.x - Python dateutil : AttributeError: module 'dateutil' has no attribute 'parse'

标签 python-3.x date parsing

尝试使用 dateutil 解析未知格式的日期,但没有找到任何记录的方法?

代码:

import dateutil
print(dateutil.parser.parse("24.05.2017"))
exit(1)

错误:
Traceback (most recent call last):
  File "test.py", line 2, in <module>
    print(dateutil.parser.parse("24.05.2017"))
AttributeError: module 'dateutil' has no attribute 'parser'

最佳答案

您可以通过稍微修改代码来修复此错误:

from dateutil import parser
print(parser.parse("24.05.2017"))

由于 dateutil 包内部如何组织其模块,因此需要进行此更改。

关于python-3.x - Python dateutil : AttributeError: module 'dateutil' has no attribute 'parse' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48632176/

相关文章:

php - 正则表达式:parse namespaces in c# source code

python - 如何在 python 3.x 中使用字符串创建 if 语句

python - Pyqt QTablewidget 自动换行

javascript - Isdate javascript 代码

python - 从 python 中的日历约会中计算空闲时间段(日期时间)

用于解析目录和文件名的正则表达式

c# - Scriban - 列出解析的表达式(变量)

python - 查找Docker镜像的依赖项

python - 模块未找到错误 : No module named 'google.appengine'

date - Java 8 - 尝试将 String 转换为 LocalDateTime