📜  在 Julia 中获取字典的键和值的类型——keytype() 和 valtype() 方法

📅  最后修改于: 2021-11-25 04:42:17             🧑  作者: Mango

keytype()是 julia 中的一个内置函数,用于返回指定数组的键类型。

例子:

Python
# Julia program to illustrate
# the use of keytype() method
 
# Getting the key type of the specified array.
println(keytype([5, 10, 15]))
println(keytype([2 4; 6 8]))
println(keytype(Dict(Int32(1) => "GFG")))
println(keytype(Dict(Int8(1) => "gfg")))


Python
# Julia program to illustrate
# the use of valtype() method
 
# Getting the value type of the specified array.
println(valtype(["Geeks", "GFG", "gfg"]))
println(valtype([1, 2, 3]))
println(valtype(Dict(Int32(1) => "GFG")))
println(valtype(Dict(Int8(1) => 23)))


输出:

valtype()

valtype()是 julia 中的一个内置函数,用于返回指定数组的值类型。

例子:

Python

# Julia program to illustrate
# the use of valtype() method
 
# Getting the value type of the specified array.
println(valtype(["Geeks", "GFG", "gfg"]))
println(valtype([1, 2, 3]))
println(valtype(Dict(Int32(1) => "GFG")))
println(valtype(Dict(Int8(1) => 23)))

输出: