Skip to content

Instantly share code, notes, and snippets.

View xlqstar's full-sized avatar

XiaoLiqun xlqstar

  • Dale tech co
  • China Changzhou
View GitHub Profile
#container{
max-width: 700px;
}
* html #container{
width: expression( document.body.clientWidth > 699 ? "700px" : "auto" );/* ie6 */
}
//编码过程中避免不了中文字符,那我们该如何提取一个中文呢?首先我们要知道string[index]获取的是字符byte,就无法像C#中"老虞"[0]来取到‘老’,在Go中需要将字符串转换成rune数组,runne数组中就可以通过数组下标获取一个汉字所标识的Unicode码,再将Unicode码按创建成字符串即可。
//查看示例代码
str :="laoYu老虞"
for i:=0;i<len(str);i++ {
fmt.Println(str[i])
}
for i,s := range str {
//**使用(多个)空格分割字符串 Fields(s string) ,返回分割后的数组 **
将字符串分割成数组,其分割符为空格。
查看示例代码
fmt.Println(strings.Fields("lao Yu Study Go ")) //OutPut: [lao Yu Study Go]
fmt.Println(strings.Fields(" Go ")) //[Go]
fmt.Println(strings.Fields("")) //[]
fmt.Println(strings.Fields(" \n go")) //[go]
package main
import "fmt"
func main() {
min, max := 0, 100
fmt.Printf("%d--%d", min, max)
for min < max {
i := (min + max) / 2
fmt.Printf("<=%d(y or n) ", i)
package main
import (
"bufio"
"log"
"os"
)
func main() {
running := true