Created
December 8, 2020 13:24
-
-
Save liangchaoboy/aae59a6980409a37fdce8f8245fc513a to your computer and use it in GitHub Desktop.
进制转换
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flag.IntVar(&base, "base", 0, "原始字符串的进制, 如果base为0,则会从字符串前置判断,”0x”是16进制,”0”是8进制,否则是10进制") | |
flag.StringVar(&parseStr, "parseStr", "", "待处理字符串") | |
flag.Parse() | |
v, err := strconv.ParseInt(parseStr, base, 64) | |
if err != nil { | |
log.Println(err) | |
} | |
fmt.Println(v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment