The difference between Python str and repr _python
Source: Internet
Author: User
Although Str (), repr () and ' operations are very similar in feature and functionality, in fact repr () and ' do the exact same thing, they return an "official" string representation of an object, which means that most of the cases can be evaluated by using the built-in function eval () To get the object back, but Str () is different. STR () is committed to generating an object's readable string representation, and its return results are generally not available for eval () evaluation, but are well suited for print statement output. Again, not all repr () returned strings can get the original object with the eval () built-in function.
That is, repr () output is friendly to Python, and str () output is friendly to the user. However, in many cases the output of these three is still exactly the same.
Everyone is interested in writing a code to compare Str,repr and "".
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service