python--string

Source: Internet
Author: User
Tags uikit

Python does not support single character types, and one character is also used as a string in Python.

str = "Hello jiao"; # before starting from index 0 to Index=-1 (contains index=0 does not contain index=-1 "index=-1 is the last character of the string") print (str[0:-1]); Hello jia# starting from index 0 to index=4 (contains index=0 does not contain index=4) print (Str[0:4]);p rint (str[: 4]); # hell# Starting from index 6 to end (contains index=6) print (str[6:]); # jiao# output two string print (str * 2); # string concatenation print (Str[0:5] + "world!!!"); 

The string hollow lattice is not omitted.

Escape character Valid

The string method will only return the modified string, the original string variable will not be changed (that is, you cannot modify a character in the string, error)

String Assignment

" Hello "  "  jiao";p rint (str);      " Jiao " ;p rint (str);   #jiao

String operators

Three quotation marks

Allows a string to span multiple lines (WYSIWYG)

Print"""<meta charset="Utf-8"/> <script src="Https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <link rel="stylesheet"href="//cdn.bootcss.com/uikit/2.25.0/css/uikit.css"/> <script src="//cdn.bootcss.com/uikit/2.25.0/js/uikit.js"></script> <link href="Http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css"Rel="stylesheet"> <script src="Http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link rel="stylesheet"href="Css/global.css"> <link rel="stylesheet"href="Css/index.css"> <script src="Js/main.js"></script>""");

String built-in functions

Reference: Python3 strings

python--string

Related Article

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.