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