Home

str

str is a common shorthand for a string, a data type used to represent text as a sequence of characters. The term is used in many programming languages and libraries, typically as a type name or a variable containing text.

In Python, str is a built-in immutable sequence type that stores Unicode characters. A value can be

Other languages treat strings differently. In C and C++, there is no standard type named str; text

Because of Unicode and encoding considerations, the storage, memory model, and performance of str values depend

created
with
a
literal
like
'hello'
or
by
calling
str()
on
an
object.
Strings
support
indexing,
slicing,
and
a
wide
set
of
methods
for
case
change,
search,
replace,
and
split.
They
can
be
encoded
to
bytes
(for
example
UTF-8)
and
decoded
back
to
text.
is
represented
by
arrays
of
char
or
by
string
classes,
and
str
is
sometimes
used
as
a
variable
name.
In
Rust,
a
string
slice
(&str)
represents
a
view
into
UTF-8
text,
while
String
is
a
growable,
heap-allocated
string.
In
many
languages
the
concept
is
simply
called
string
or
text,
with
varying
semantics
for
mutability
and
encoding.
on
language,
encoding,
and
operations
used.
Understanding
the
specific
language's
string
type
is
important
for
correct
handling
of
text,
interoperability,
and
performance.