2-6 Sayings 2: Repeat exercise 2-5, but store the name of the celebrity in the variable Famous_person, and then create
To display the message and store it in the variable message, and then print the message.
'Albert Einstein'a person whonever made a mistake never tried anything new.' Print (Famous_person +" once Said,\""+message +"\ ".")
To pay special attention to the \ "escape character
F5 Run
Albert Einstein once said, "a person who never made A mistake never tried anything new."
2-7 eliminate whitespace in people's names: stores a person's name and contains some whitespace characters at the beginning and end of it.
Be sure to use at least one character combination of "\ t" and "\ n".
Print the name to show the white space at the beginning and end of it. Then, using the Culling function lstrip (), respectively,
Rstrip () and strip () process the names and print the results.
"Print (" Name is:\n "+ test_name) print ("\ t"+test_name)print(Test_name.strip ()) Print (Test_name.rstrip ()) Print (Test_name.lstrip ())
F5 Run:
Name is:
Li Xiao Long
Li Xiao Long
Li Xiao Long
Li Xiao Long
Li Xiao Long
4. String (2-6/2-7)