String: cut case to replace spaces

# .lower converted into a lowercase string 

A = INPUT ( ">>>")
A1 = a.lower ()
Print (A1)

# .upper string converted to uppercase 

A = INPUT ( ">>>")
Print (A.upper ())

# .isdigit checks whether a decimal number 

A = INPUT ( ">>>")
A1 = a.isdigit ()
Print (A)
Print (A1) is the result of type bool # True Fals
# Result 
>>> 3
3
True

# .rstrip removing the right spaces 
# .lstrip removal spaces left
#strip clear space removed
name = input ( 'Enter your user name spaces :( craniocaudal)')
NAME1 = name.rstrip ()
NAME2 = name.lstrip ()
NAME3 = name.strip ()
Print ( '---', name, '---')
Print ( '---', NAME1, '---')
Print ( '---', NAME2, '- - ')
Print (' --- ', NAME3,' --- ')
# enter a user name spaces :( craniocaudal) da fdsf fafg # enter
# --- da fdsf fafg --- # outputs the original
# - - da fdsf fafg --- # output the right space to remove
# --- da fdsf fafg --- # output left blank to remove
# --- da fdsf fafg --- # output clear space removal


Alternatively sensitive # .replace word 
count = input ( 'Enter a text:')
A = count.replace ( 'uncle', '**', 2) replacing the word sensitive # ** appears two times before
print (a)
Print (COUNT)

# output:
# Please enter a text: Grandpa Grandpa Grandpa
# **** uncle
# uncle Grandpa Grandpa

# Rsplit cutting Split 
A = INPUT ( 'Enter a string:')
V = a.split ( 'A',. 1)
V1 = a.rsplit ( 'A',. 1)
Print (V)
Print (V1)

# results
# enter a text: afasfasdfaf
# [ '', 'fasfasdfaf']
# [ 'afasfasdf', 'F']



Guess you like

Origin www.cnblogs.com/yeers/p/11516697.html