问题标签 [python-dateutil]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - ImportError:matplotlib 需要 dateutil;将 matplotlib.pyplot 导入为 plt
我是编程和 Python 的新手,当我运行我的程序时,我不断收到以下错误。有人建议我应该使用 pip 来解决它。但是无法使用 cmd 安装 pip。虽然我成功使用了 Powershell,但仍然无法使其工作。我该如何解决这个问题,任何提示都会继续进行。谢谢
我正在使用 2.7.3 版
python - 在 Python 中解析人类可读的重复日期
问题。在我的 Django 应用程序中,用户为计划执行创建任务。用户是相当非技术性的,如果他们可以编写常规的人类可读表达式来定义何时执行某些任务,那就太好了,例如:
- 每逢星期一
- 每周五、周三
- 日常的
- 每月 1 日、14 日、20 日
- 每个星期五;每个月底
这是由Todoist启发的。目前,只需要日期;没有时间。我花了几个小时在谷歌上搜索图书馆来做到这一点,但没有运气。我期待一个函数,比如说,,in_range(expression, date)
这样:
变体。这就是我看过的。
- 标准
datetime
库进行日期解析,但不是如上所述的日期范围解析。 - Python-dateutil - 通过 支持重复日期
rrule
,非常实用,但仍然不支持解析。 - Python-crontab和Python-croniter接受标准的 Unix crontab 语法(并允许指定工作日等),但这种语法仍然过于技术性,我想尽可能避免使用它。
- Arrow和Parsedatetime不支持该功能。
那么,是否有 Python 代码片段或我错过的库来做这件事?如果没有,我将自己编写解析器。如果它看起来还不错,想在开源中发布它。
python - 使用“import dateutil”和“dateutil.parser.parse()”时出现AttributeError,但使用“from dateutil import parser”时没有问题
我正在使用 Python 2.7.3 中的dateutil
模块。我只是想使用:
但我得到一个错误:
我检查了哪些属性dateutil
有:
问题是,当我尝试直接导入parser
时dateutil
,它似乎确实存在:
之后from dateutil import parser
,parser
也神奇地出现在了导入的dateutil
本身中:
请注意,rrule
此列表中仍然缺少一些其他属性(如 )。
有谁知道发生了什么?
python - 日期时间和 relativedelta 的奇怪算术
乘法relativedelta
对象是否安全?我看到一些奇怪且不一致的行为,并且找不到它记录了此类支持哪些类型的算术(如果有的话)
另一方面:
完整回溯(使用python
2.7.5 和dateutil
1.5):
django - 当它包含在 requirements.txt 中时,部署到 heroku 无法部署“no module dateutil.parser”
我是 django newby,这是我在 StackOverflow 上发布的第一个问题:
在过去的一个月里,我已经成功地将几个应用程序部署到 heroku,但是当我添加一个导入 dateutil.parser 的模块 fixed2csv 时,即使它在 requirements.txt 文件中,heroku 也无法找到该模块。
这是heroku的部署消息的片段......
包 python-dateutil
fixed2csv Traceback(最近一次调用最后一次):文件“”,第 17 行,在文件“/tmp/pip_build_u20147/fixed2csv/setup.py”中,第 7 行,在 import fixed2csv 文件“fixed2csv.py”,第 10 行,在 import dateutil 中.parser ImportError: No module named dateutil.parser 命令 python setup.py egg_info 的完整输出:Traceback(最近一次调用):
!推送被拒绝,无法编译 Python 应用程序
当我安装 python-dateutil 时,在我的 virtualenv 中一切正常,所以我不确定从这里去哪里。
更新:我通过不使用需要 python-dateutil 的模块来解决它。我很想知道如何让 Heroku 识别 python-dateutil,因为它比使用 strptime 格式字符串更好用。
python - Python's dateutil.tz.tzstr fails on string argument
With dateutil
2.2, I can't get the tzstr
examples working (see below). It throws an error 'str' object has no attribute 'read'
. Looking at the code, it fails on self.instream.read(1)
. What type should I be passing it?
python - Python / Mongoengine - 保存到数据库时缺少时区?
我在使用 MongoEngine 将日期对象保存到 Mongo 时遇到了一些问题。这是我的代码:
本地化日期似乎工作正常,但保存到 Mongo 时:
当我查看创建的 Mongo 文档时,会发生以下奇怪现象:
是否有任何原因导致时间相差两个小时,并且时区不再存在?
python - dateutil.parser.parse() 和丢失的时区信息
我正在尝试使用时区感知日期dateutil.parser.parse()
时间解析默认输出。str(datetime.datetime.now())
但是,parse()
似乎丢失了时区信息并将其替换为本地时区。下面是 IPython 输出:
据我了解dateutil
,在猜测日期格式时会进行一些启发式操作,并且这里可能会出错。
如何为解析时区感知的日期时间提供准确的日期时间格式?
更好 - 如果知道格式如何仅使用 Python stdlib 解析此日期时间,而不依赖于 dateutil?
python - 将日期时间转换为 strptime
我正在提取一个看起来像这样的时间戳 - 2014-02-03T19:24:07Z
我正在尝试计算自 1 月 1 日以来的天数。
我能够使用将其转换为日期时间
但现在我正在尝试解析它并获取单个元素,例如月份和日期。
有没有办法将它转换为 strptime 以便我可以选择每个元素?
python - Dateutil's parser on February not parsing
I am getting a very strange bug in python.
Traceback (most recent call last):
File "", line 1, in File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/parser.py", line 697, in parse return DEFAULTPARSER.parse(timestr, **kwargs) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/parser.py", line 310, in parse ret = default.replace(**repl) ValueError: day is out of range for month
I understand that I can add a day to my string to make the parser work, but I have no idea why dateutil does not work without the day for February, while it works for every other month.