go routine和字符,实际是数字
点击查看代码
package main
import (
"fmt"
"time"
)
func numbers() {
for i := 1; i <= 5; i++ {
time.Sleep(250 * time.Millisecond)
fmt.Printf("%d ", i)
}
}
func alphabets() {
for i := 'a'; i <= 'e'; i++ { // 此处的i是`a`对应的ascii码的数字位置
time.Sleep(400 * time.Millisecond)
fmt.Printf(" (%c>>%d--%v) " , i,i,i)
}
}
func main() {
go numbers()
go alphabets()
time.Sleep(3000 * time.Millisecond)
fmt.Println("main terminated")
}
写入自己的博客中才能记得长久