【发布时间】:2021-09-02 17:27:18
【问题描述】:
我正在运行一个使用以下包的 python 脚本
from dateutil.parser import parse
图书馆包括以下内容
"""This will take any date string and format into the date format you want
Args:
date_str (string): Any date string
format (string): format you want
Example:
>>> my_date_format = format_date("2020-10-03", "%m/%d/%Y")
>>> my_date_format = format_date("2020/10/03", "%m/%d/%Y")
>>> my_date_format = format_date("10/03/2020", "%m-%d-%Y")
>>> my_date_format = format_date("2018-06-29 08:15:27.243860", "%m-%d-%Y %H:%M:%S.%f")
>>> my_date_format = format_date("10/06/2020 at 7:40AM", "%b %d %Y at %I:%M%p")
"""
dt = parse(date_str)
return dt.strftime(format)
但是,当我运行任何利用上述内容的东西时,我会收到以下错误:
Traceback (most recent call last):
File C:\Users\main\box\scripts\tests>python ra.py", line 26, in <module>
from UtilLib import CodeStore, check_if_file_exists, getRandomUserInfo
File "..\UtilLib.py", line 19, in <module>
from dateutil.parser import parse
File "C:\Python39\lib\site-packages\dateutil\parser.py", line 158
l.append("%s=%s" % (attr, `value`))
^
SyntaxError: invalid syntax```
The error seems to be associated with the dateutil package that was installed. I can't figure out how to fix this. Where do I start?
【问题讨论】: