好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python字符串处理函数大总结

str='python String function'

7.字符串判断相关

是否以start开头:str.startswith('start')

是否以end结尾:str.endswith('end')

是否全为字母或数字:str.isalnum()

是否全字母:str.isalpha()

是否全数字:str.isdigit()

是否全小写:str.islower()

是否全大写:str.isupper()

str='python String function'

print '%s startwith t=%s' % (str,str.startswith('t'))

print '%s endwith d=%s' % (str,str.endswith('d'))

print '%s isalnum=%s' % (str,str.isalnum())

str='pythonStringfunction'

print '%s isalnum=%s' % (str,str.isalnum())

print '%s isalpha=%s' % (str,str.isalpha())

print '%s isupper=%s' % (str,str.isupper())

print '%s islower=%s' % (str,str.islower())

print '%s isdigit=%s' % (str,str.isdigit())

str='3423'

print '%s isdigit=%s' % (str,str.isdigit())

查看更多关于python字符串处理函数大总结的详细内容...

  阅读:35次