Python uses str & repr to convert the string, pythonstr
It may be better to record low:
Use of str and repr
Str is a type (int, long is similar). It can also be used as a string for a factory Method Instance.
Repr is a built-in function of
may be low or record:
The use of STR and REPR
STR is a type (int, long is similar), and she can also act as a string for a factory method instance
Repr is a python-built function that preserves the true state of a printed value in a
There are two types of python3 that represent the sequence of characters: bytes and str. An instance of the former contains the original 8-bit value, and the instance of the latter contains Unicode characters.There are also two types of python2 that
Python built-in data operations (1) --- string str, pythonstr
S. capitalize ()-> str Return a capitalized version of S, I. e. make the first character have upper case and the rest lower case.Returns an upper-case string that converts the first
This function is implemented to return a string object. The argument object is the one to convert the content to, the parameter encoding is the encoding method,and theerrors is the error handling method. Example:#str () print (str (b ' abc '))
Here is my understanding. If there is something wrong with me. Please be sure to tell me. Thank you!
In python, __str _ is generally in this format.
Class:
Def _ STR _ (Self ):
Return "this is in Str"
In fact, __str _ is called by the print
absrtact : When writing Python scripts, if we use Python to process Web page data or work with Chinese characters, this error message often occurs: syntaxerror:non-ascii character ' \ Xe6 ' in file./filename.py of Line 3, but no encoding declared.
[Python Basics] str string, pythonstr string
The str string is an unchangeable object.1. Create a string
S1 = str () # create an empty string s2 = str ("hello") # create a string "hello"
2. Common functions and operations for processing strings (1).
In Python, there are usually two ways to convert a variable or constant of a certain type to a string object, namely str () or repr ().Difference and useThe function str () is used to convert a value into a form suitable for human reading, while
This article mainly introduces how to use str (string) in python3, which is very detailed. operations on various str strings in python3 are included in this article, if you want to learn more, let's take a look. This article mainly introduces how to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.