`
woxiaoe
  • 浏览: 276568 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论

python字符串

阅读更多

s = "woxiaoe"

print len(s)

print "s[0] " + s[0] + '\t' + 's[1] ' + s[1];

print "s[-1] " + s[-1] + '\t' + 's[-2] ' + s[-2];

print s*10

 

print 'asS'.isalpha();

print dir(s);

help(s.decode)

msg = '''

adsfsafas"""asdafa"""dddd

sdfs'''

print msg

 

输出

 

7

s[0] w s[1] o

s[-1] e s[-2] o

woxiaoewoxiaoewoxiaoewoxiaoewoxiaoewoxiaoewoxiaoewoxiaoewoxiaoewoxiaoe

True

['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']

Help on built-in function decode:

 

decode(...)

    S.decode([encoding[,errors]]) -> object

 

    Decodes S using the codec registered for encoding. encoding defaults

    to the default encoding. errors may be given to set a different error

    handling scheme. Default is 'strict' meaning that encoding errors raise

    a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'

    as well as any other name registered with codecs.register_error that is

    able to handle UnicodeDecodeErrors.

 

 

adsfsafas"""asdafa"""dddd

sdfs

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics