Home>Article>Backend Development> What does str mean in python

What does str mean in python

silencement
silencement Original
2019-05-22 16:05:16 198268browse

The meaning of str in python: 1. Represents the string class, you can use quotation marks (' or ") to create a string, for example "str='Hello World!'"; 2. Represents str() Function, convert the object into a form suitable for human reading. The syntax is "str(object='')" and returns the string format of an object.

What does str mean in python

1. Indicates the string class

You can use quotation marks (' or ") to create a string

The method of creating a str string is as follows:

What does str mean in python

The commonly used methods of str are as follows:

What does str mean in python

Indexing and slicing of str:

What does str mean in python

When encoded with utf-8, one Chinese character is equal to three characters. When using gbk encoding, one Chinese character is equal to two characters.

2. Express the str() function

The str() function is used to convert objects into a form suitable for human reading.

Syntax:

class str(object='')

Parameters

  • object -- Object.

Return value: Returns the string format of an object.

The following shows an example of using the str() method:

>>>s = 'RUNOOB' >>> str(s) 'RUNOOB' >>> dict = {'runoob': 'runoob.com', 'google': 'google.com'}; >>> str(dict) "{'google': 'google.com', 'runoob': 'runoob.com'}" >>>

The above is the detailed content of What does str mean in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn