The Go Programming Language
› http://golang.org/
› Go Playground
Go Projects
› Revel Web Framework
keepfun

问一个 golang 截取的疑问

  •  
  •   keepfun · Aug 16, 2021 · 1659 views
    This topic created in 1891 days ago, the information mentioned may be changed or developed.
    package main
    
    func main(){
    	str := "wcd"
    	print(str[len(str)])  // panic
    	print(str[len(str):]) // 输出为空
    }
    
    

    代码如上

    为啥一个是 panic 一个可以输出为空

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1128 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 18:12 · PVG 02:12 · LAX 11:12 · JFK 14:12
    ♥ Do have faith in what you're doing.