Learn Python 002: String Method
text = 'happy python learning'
print(text.count('n'))
text = text.upper()
print(text)
text = text.capitalize()
print(text)
text = text.title()
print(text + '\n')
text = ' 000000happy python learning0000000 '
print(text.strip('0'))
print(text.lstrip('0'))
print(text.rstrip('0'))
print(text.strip())
name = input('What is your name?\n').strip()
#there is another way but not as good:
#print(name.strip())

浙公网安备 33010602011771号