Skip to content
Docs
Modules
strconv

strconv

String conversion functions from the Go standard library.

Functions

atoi

Function signature
atoi(s string) int

Converts the string s to an int.

Example
>>> strconv.atoi("123")
123
>>> strconv.atoi("nope")
strconv.Atoi: parsing "nope": invalid syntax

parse_bool

Function signature
parse_bool(s string) bool

Converts the string s to a bool.

Example
>>> strconv.parse_bool("true")
true
>>> strconv.parse_bool("false")
false
>>> strconv.parse_bool("nope")
strconv.ParseBool: parsing "nope": invalid syntax

parse_float

Function signature
parse_float(s string) float

Converts the string s to a float.

Example
>>> strconv.parse_float("3.14")
3.14
>>> strconv.parse_float("nope")
strconv.ParseFloat: parsing "nope": invalid syntax

parse_int

Function signature
parse_int(s string, base int = 10, bit_size int = 64) int

Converts the string s to an int.

Example
>>> strconv.parse_int("123")
123
>>> strconv.parse_int("nope")
strconv.ParseInt: parsing "nope": invalid syntax
>>> strconv.parse_int("ff", 16)
255