码迷,mamicode.com
首页 > 其他好文 > 详细

string对象方法

时间:2019-04-06 19:19:48      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:html   pytho   cte   href   class   types.h   lower   rip   ica   

技术图片

一:str.isalnum()str.isalpha()str.isdigit()str.islower()str.isupper() 

1.str.isalnum() 
This method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9).

>>> print ‘ab123‘.isalnum()
True
>>> print ‘ab123#‘.isalnum()
False

2.str.isalpha() 
This method checks if all the characters of a string are alphabetical (a-z and A-Z).

>>> print ‘abcD‘.isalpha()
True
>>> print ‘abcd1‘.isalpha()
False

3.str.isdigit() 
This method checks if all the characters of a string are digits (0-9).

>>> print ‘1234‘.isdigit()
True
>>> print ‘123edsd‘.isdigit()
False

4.str.islower() 
This method checks if all the characters of a string are lowercase characters (a-z)

>>> print ‘abcd123#‘.islower()
True
>>> print ‘Abcd123#‘.islower()
False

5.str.isupper()  

This method checks if all the characters of a string are uppercase characters (A-Z). 

>>> print ‘ABCD123#‘.isupper()
True
>>> print ‘Abcd123#‘.isupper()
False

  

  

  

string对象方法

标签:html   pytho   cte   href   class   types.h   lower   rip   ica   

原文地址:https://www.cnblogs.com/Mr-l/p/10662270.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!