Home >Backend Development >Python Tutorial >Detailed introduction to python strings
Python has five major data types, which are: Use the type built-in function to view the data type
1: str (string) 2: int (integer) 3: float (floating point number)
3: list (list) 4: dict (dictionary) 5: set (set)
str (string) is an immutable type: the value corresponding to each variable is actually only in memory Associating data with variable names, when the value of B is modified, it is actually just opening up a new space in the memory, pointing B to the newly opened space, and does not directly change the data in the memory space that B originally pointed to: as shown in the figure
Python has many built-in methods for each data type. Flexible use of these methods can greatly reduce the amount of our code. Below I list the methods of strings for everyone. Some common methods:
str.replace() // String replacement
##str.strip('/') str.split() ##str.startswith() Change the string to lowercase
##str.upper() ’’’’’
#'Specify splicing symbol'.join(str) //String splicing
String slice:
## characters String splicing:
There are many built-in methods for strings, but these are the most commonly used ones. I hope it will be helpful to all my friends.
The above is the detailed content of Detailed introduction to python strings. For more information, please follow other related articles on the PHP Chinese website!