我正在学习V,就我的尝试而言,尽管V字符串是一个字节数组,但数组方法不适用于字符串。所以我想把一个字符串转换成一个数组。我试着搜索这个,但没有成功,我在Go中找到了一些东西,但它在V中不可用:
[]byte("Here is a string....")有没有办法将字符串转换为V中的数组?
发布于 2021-06-28 16:22:19
您可以使用string.split(delim string)来仅使用array,使用string.bytes()来获取bytes的array:
Welcome to the V REPL (for help with V itself, type `exit`, then run `v help`).
V 0.2.2 8650ec6
Use Ctrl-C or `exit` to exit, or `help` to see other available commands
>>> x := "test"
>>> x.split("")
['t', 'e', 's', 't']
>>> x.bytes()
[t, e, s, t]https://stackoverflow.com/questions/68084259
复制相似问题