作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将日志日期列表解析为 DateTime
实例,但它会引发不精确的错误。我做错了什么,我该怎么做?
julia> using Base.DateTime
julia> readdlm("push-log.txt")[:,1]
16-element Array{Any,1}:
"2016-06-22T14:04:09.9896422Z"
"2016-06-22T14:04:10.0052910Z"
"2016-06-22T14:04:11.3177753Z"
"2016-06-22T14:04:12.3334265Z"
"2016-06-22T14:04:13.4896544Z"
"2016-06-22T14:04:14.1459007Z"
"2016-06-22T14:04:14.6459071Z"
"2016-06-22T14:04:15.6615276Z"
"2016-06-22T14:04:16.2084073Z"
"2016-06-22T14:04:17.2865371Z"
"2016-06-22T14:04:18.3490382Z"
"2016-06-22T14:04:19.2396584Z"
"2016-06-22T14:04:19.7709572Z"
"2016-06-22T14:04:20.9584180Z"
"2016-06-22T14:04:22.0209160Z"
"2016-06-22T14:04:22.6615594Z"
julia> map(readdlm("push-log.txt")[:,1]) do str
DateTime(str, "y-m-dTH:M:S.sZ")
end
ERROR: InexactError()
in slotparse at dates/io.jl:131
in getslot at dates/io.jl:143
in parse at dates/io.jl:158
in anonymous at none:2
in map at essentials.jl:153
julia> versioninfo()
Julia Version 0.4.6
Commit 2e358ce (2016-06-19 17:16 UTC)
Platform Info:
System: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.3
最佳答案
来自 docs :
The
Date
s module provides two types for working with dates:Date
andDateTime
, representing day and millisecond precision, respectively;
DateTime
抛出一个
InexactError
解析超过三位小数的时间戳时。将其限制为三位小数有效:
julia> t = "2016-06-22T14:04:22.6615594Z"
"2016-06-22T14:04:22.6615594Z"
julia> DateTime(t,"y-m-dTH:M:S.sZ")
ERROR: InexactError()
in slotparse at dates/io.jl:131
in getslot at dates/io.jl:143
in parse at dates/io.jl:158
julia> t2 = "2016-06-22T14:04:22.662Z"
"2016-06-22T14:04:22.662Z"
julia> DateTime(t2,"y-m-dTH:M:S.sZ")
2016-06-22T14:04:22.662
DateTime
无法处理
Millisecond
的小数部分:
julia> Base.Dates.Millisecond(111)
111 milliseconds
julia> Base.Dates.Millisecond(111.1)
ERROR: InexactError()
in call at dates/types.jl:18
关于datetime - 在 Julia 中解析祖鲁语日期会引发 InexactError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37971649/
我仍在学习 Julia 语言,但出现此错误。我正在编写一个蚊子种群模型,我正在尝试运行我的主要功能 100 次。此主函数使用许多其他函数来计算子种群水平。 # Importing KNMI data
我正在尝试将日志日期列表解析为 DateTime实例,但它会引发不精确的错误。我做错了什么,我该怎么做? julia> using Base.DateTime julia> readdlm("push
我有这段代码可以使用 IPNewton method 优化函数( error.jl ): import Optim """ Generate a matrix of constants used in
我是一名优秀的程序员,十分优秀!