Analysis of basic Python String applications

Source: Internet
Author: User

The Python String type can bring us great benefits in practical applications. In the next article, we will introduce the Python String-type application methods in detail here. I hope you can fully master this application.

Python String application code example:

 
 
  1. >>> 'hello world'  
  2. 'hello world'  
  3. >>> "hello world"  
  4. 'hello world'  
  5. >>> "doesn't"  
  6. "doesn't"  
  7. >>> 'hello "tom"'  
  8. 'hello "tom"'  
  9. >>> "hello,\"tom\""  
  10. 'hello,"tom"'  
  11. >>> hello="hello,\  
  12. i miss you."  
  13. >>> print(hello)  
  14. hello,i miss you.  
  15. >>> print(r"hello\n world")  
  16. hello\n world  
  17. >>> word='hello'+'A'  
  18. >>> print(word)  
  19. helloA  
  20. >>> word[0:5]+'B'  
  21. 'helloB'  
  22. >>> word[-1]  
  23. 'A'  
  24. >>> len(word) 

Note:

  • Main steps for Python to call. net framework
  • Python coding experience in creating Silverlight controls
  • Python parsing XML correct application code example
  • Analysis of Python image Optimization Techniques
  • Python file path

Single quotation marks 'and double quotation marks "have the same effect and are used to represent strings. However, single quotation marks' can contain double quotation marks" ", double quotation marks '', however, if double quotation marks "" are used in double quotation marks "" or single quotation marks ''are used in single quotation marks, escape characters must be used, such as \ 'or \".

The end of the line \ indicates the string line break.

The r before the string indicates a pure string, and The Escape Character in the string is invalid.

+ Indicates the link of a string.

[] Can be used to index characters in a string, but cannot be used to modify characters in a string.

Len () is used to obtain the length of a string.

The above is an introduction to the Python String type.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.