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

问一个 golang 截取的疑问

  •  
  •   keepfun · Aug 16, 2021 · 1612 views
    This topic created in 1874 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   ·   2235 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 06:16 · PVG 14:16 · LAX 23:16 · JFK 02:16
    ♥ Do have faith in what you're doing.