strip的用法是去除字符串中前后两端的xx字符,xx是一个字符数组,并不是去掉“”中的字符串, 数组中包含的字符都要在字符串中去除.默认去掉空格,lstrip则是去掉左边的,rstrip是右边的 见代码: In [1]: s = ' abc ' In [2]: s.strip() Out[2]: 'abc' In [3]: s = 'abc def abc' In [4]: s.strip() Out[4]: 'abc def abc' In [5]: s.strip('abc') Out[5
// golang中是没有判断字符串是否存在数组或切片里的内置方法, 所以我们可以自己搞一个快速小组件 func Find(slice []string, val string) (int, bool) { for i, item := range slice { if item == val { return i, true } } return -1, false } func main() { var dataList []string{"test1", "test2&