【发布时间】:2013-12-29 16:26:09
【问题描述】:
我正在尝试在 Go 中查找“@”字符串字符,但找不到方法。我知道如何索引像“HELLO[1]”这样会输出“E”的字符。但是我正在尝试查找找到的字符的索引号。
在 Python 中,我会采用以下方式:
x = "chars@arefun"
split = x.find("@")
chars = x[:split]
arefun = x[split+1:]
>>>print split
5
>>>print chars
chars
>>>print arefun
arefun
因此,在使用“@”分隔符时,chars 将返回“chars”,而 arefun 将返回“arefun”。我一直在努力寻找解决方案几个小时,但我似乎无法在 Golang 中找到合适的方法。
【问题讨论】: