sliceing

来源:互联网 发布:elsevier数据库主页 编辑:程序博客网 时间:2024/05/16 01:38

testString = '<a herf="http://www.python.org">python web site </a>'print testString[0:1]print testString[9:30]print testString[32:-4]print testString[-3:0]print testString[-3:1]print testString[-3:]print testString[:-3]print testString[:]#step > 1print testString[0:10:1]print testString[0:10:2]print testString[::4]print testString[:10:2]print testString[10:0:-2]

执行结果:

<

http://www.python.org
python web site 




/a>
<a herf="http://www.python.org">python web site <
<a herf="http://www.python.org">python web site </a>
<a herf="h
< ef"
<e"pwporpoei<
< ef"
t"fe 
原创粉丝点击