1. Modify the case
(1) Title () displays each word in uppercase, with the first letter of each word capitalized. This is useful,
Because you often need to treat your name as information. For example, you might want the program to treat the value Ada, Ada, and Ada as the same name,
and show them all as Ada
(2) Upper ()/lower () to change the string to all uppercase or all lowercase,
Where data is stored, method lower () is useful. Many times, you can't rely on users to provide the right case, so
You need to convert the strings to lowercase first, and then store them. When you need to display this information later, convert it to the most appropriate large
lowercase mode.
2. Merging (splicing)
Python uses a plus sign (+) to combine characters, and this method of merging strings is called stitching. By stitching, you can use the information stored in a variable to create a complete message.
3. Use line breaks or tabs to add whitespace
To add a tab, you can use the character combination \ t.
To add line breaks, use the character combination \ n.
4. Delete blank
You can use the Rstrip () function to find extra whitespace at the beginning and end of a string. Make sure there is no white space at the end of the string.
Only temporary, not permanently deleted.
You can also use the method Lstrip () and strip () to remove whitespace at the beginning or both ends.
string manipulation of Python