a ='studesnt'
print(a.capitalize())
print(a.count('s'))
#字符串的位置查找返回的下标中,字符串的第一个字符的下标定义 为0.
print(a.find('n'))
print(a.find('o'))
print (a.index('d'))
print(a.replace('t','d'))
----------------------------------------------------------------------------------------
Studesnt
2
6
-1
3
sdudesnd
#字符串中的空格是不会去掉的
a =' stud esnt '
print(a.strip())
print(a.strip('t'))
a =' studesnt '
print(a.strip())
print(a.strip('t'))
——————————————————————————————————————————————————————————
stud esnt
stud esnt
studesnt
studesnt #未实现,原因不明
a =' studesnt '
print(a.isalnum())
————————————————————————————————————————————
False
标签:内置,函数,studesnt,print,stud,strip,字符串,esnt From: https://www.cnblogs.com/yuyuboy/p/17264772.html