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
本文通过一个简单的Python脚本示例,介绍了字符串的基本操作方法,包括长度获取、字符访问、重复输出、判断是否全为字母、展示字符串内置方法及帮助信息等。此外,还展示了如何在字符串中使用特殊字符。
1万+

被折叠的 条评论
为什么被折叠?



