多个fmt.Scanf()输入方式: asdfasdfdfasdfsdfas空格d
点击查看代码
package main
import (
"fmt"
"strings"
)
func StrIndex(str string, substr string) (int, int) {
fmt.Printf("str=%s,substr=%s \n",str,substr)
return strings.Index(str, substr), strings.LastIndex(str, substr)
}
func main() {
var (
str string
substr string
)
fmt.Printf("Please Input Str: ")
fmt.Scanf("%s", &str)
fmt.Printf("Please Input Substr: ")
fmt.Scanf("%s", &substr)
fmt.Println(StrIndex(str, substr))
}