String constants 应用

 

>>> import string
>>> string.ascii_letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'
>>> string.ascii_uppercase
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> string.digits
'0123456789'
>>> string.hexdigits
'0123456789abcdefABCDEF'
>>> string.letters
Traceback (most recent call last):
  File "<pyshell#98>", line 1, in <module>
    string.letters
AttributeError: 'module' object has no attribute 'letters'
>>> string.octdigits
'01234567'
>>> string.punctuation
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
>>> #punctuation[英][ˌpʌŋktʃuˈeɪʃn][美][ˌpʌŋktʃuˈeʃən]
n.标点符号
Traceback (most recent call last):
  File "<pyshell#101>", line 2, in <module>
    n.标点符号
NameError: name 'n' is not defined
>>> string.printable
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
>>> string.whitespace
' \t\n\r\x0b\x0c'

 

posted @ 2015-07-31 13:57  hhj187  阅读(581)  评论(0编辑  收藏  举报