【发布时间】:2017-03-10 21:43:59
【问题描述】:
我想在 Julia 中将整数转换为字符串。
当我尝试时:
a = 9500
b = convert(String,a)
我得到错误:
ERROR: LoadError: MethodError: Cannot `convert` an object of type Int64 to an object of type String
This may have arisen from a call to the constructor String(...),
since type constructors fall back to convert methods.
in include_from_node1(::String) at ./loading.jl:488
in process_options(::Base.JLOptions) at ./client.jl:265
in _start() at ./client.jl:321
while loading ..., in expression starting on line 16
我不确定为什么 Int64 不能转换为字符串。
我尝试将a 定义为不同的类型,例如a = UInt64(9500),但得到了类似的错误。
我知道这是非常基本的,并尝试寻找正确的方法来做到这一点here,但无法弄清楚。
【问题讨论】:
标签: string floating-point type-conversion julia