我正在尝试在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中正确执行此操作的方法。