Home > other >  String. Capwords () function USES the confusion
String. Capwords () function USES the confusion

Time:10-29



1, the string contains a lot of space inside, do not use the parameter when

W1='hello, I am baby, my father, my brother, my sister! '
Print (string) capwords (w1))

The output is
Hello, I Am Baby, my Father, my Brother, my Sister!

Delete the redundant space, and has carried on the capital to the first letter of certain words,

2, the use of parameters, we set for the parameter m
W1='hello, I am baby, my father, my brother, my sister! '
Print (string. Capwords (w1, 'm'))

The output
Hello, I am baby, mY father, mY brother, mY sister!

Parameters at the back of the letters to uppercase, but not delete the redundant Spaces,

Other books teach string. Capwords (w1, [m]) is the use of this format, but I always error, using square brackets instead of single quotation marks after the print (string) capwords (w1, 'm')), programs can run normally, is this why? Under the great god will help me understand this problem?
  • Related