代码拉取完成,页面将自动刷新
mystr='PythonInteresting'
print('字符串字符大小写变换函数示例:')
print('%s lower=%s' % (mystr,mystr.lower()))
print('%s upper=%s' % (mystr,mystr.upper()))
print('%s swapcase=%s' % (mystr,mystr.swapcase()))
print('%s capitalize=%s' % (mystr,mystr.capitalize()))
print('%s title=%s' % (mystr,mystr.title()))
print('字符串格式相关函数示例:')
print('%s ljust=%s' % (mystr,mystr.ljust(20)))
print('%s rjust=%s' % (mystr,mystr.rjust(20)))
print('%s center=%s' % (mystr,mystr.center(20)))
print('%s zfill=%s' % (mystr,mystr.zfill(20)))
print('字符串搜索相关函数示例:')
print('%s find on=%d' % (mystr,mystr.find('on')))
print('%s find t=%d' % (mystr,mystr.find('t')))
print('%s find t from %d=%d' % (mystr,1,mystr.find('t',1)))
print('%s find t from %d to %d=%d' % (mystr,1,2,mystr.find('t',1,2)))
print('%s rfind t=%d' % (mystr,mystr.rfind('t')))
print('%s count t=%d' % (mystr,mystr.count('t')))
print('字符串替换相关函数示例:')
print('%s replace t to *=%s' % (mystr,mystr.replace('t', '&')))
print('%s replace t to *=%s' % (mystr,mystr.replace('t', '&',1)))
print('字符串分隔相关函数示例:')
mynewstr='apple banana orange peach'
print('%s strip=%s' % (mynewstr,mynewstr.split()))
mynewstr='apple;banana;orange;peach'
print('%s strip=%s' % (mynewstr,mynewstr.split(';')))
print('字符串判断相关函数示例:')
print('%s startwith t=%s' % (mystr,mystr.startswith('P')))
print('%s endwith d=%s' % (mystr,mystr.endswith('m')))
print('%s isalnum=%s' % (mystr,mystr.isalnum()))
print('%s isalnum=%s' % (mystr,mystr.isalnum()))
print('%s isalpha=%s' % (mystr,mystr.isalpha()))
print('%s isupper=%s' % (mystr,mystr.isupper()))
print('%s islower=%s' % (mystr,mystr.islower()))
print('%s isdigit=%s' % (mystr,mystr.isdigit()))
strnew='3478'
print('%s isdigit=%s' % (strnew,strnew.isdigit()))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。