Use of python strings, use of python strings
I have read some of the most basic python tutorials on the Internet. They are easy to understand, but they still feel quite cool in the process of writing. You should write more and practice the use of strings!
The idea is: Take "#" as the delimiter and take "teacher_id = 123" on the left ([0] indicates the first index position ), then remove the spaces on both sides (using strip (), take "teacher_id" with "=" as the delimiter, and remove the spaces on both sides. The printed result is similar to "teacher_id: 123"
Common string operations are summarized as follows:
① Remove spaces and some special symbols ('#', '|', etc ):
Remove spaces on both sides of the string: str. strip ()
Delete the space at the end of the string: str. lstrip ()
Delete the space on the left of the string: str. rstrip ()
② String segmentation (blank characters by default ):
Str. split ()
③ String SEARCH:
Str. find () # The index location is returned.
④ Calculate the string length:
Len (str)
⑤ String case:
Str. upper () # uppercase letters
Str. lower () # lowercase letters
Str. capitalize () # uppercase letters
Str. istitle () # whether it is an uppercase letter
Str. isupper () # whether the letter is in upper case
Str. islower () # whether all letters are in lower case