2013年10月24日

Python Cookbook学习记录 ch1_13_2013/10/24

摘要: 1.13访问子字符串a.使用切片,但是切片一次只能取得一个字段b.使用struct.unpack方法import struct# Get a 5-byte string, skip 3, get two 8-byte strings, then all the rest:baseformat = "5s 3x 8s 8s"# by how many bytes does theline exceed the length implied by this# base-format (24 bytes in this case, but struct.calcsize is g 阅读全文

posted @ 2013-10-24 23:17 七海之风 阅读(175) 评论(0) 推荐(0)

Python Cookbook学习记录 ch1_12_2013/10/24

摘要: ch1_11 PASS1.12 控制大小写首先是大家都很熟悉的upper()和lower()文中还介绍了capitalize()和title(),capitalize()的作用是将第一个字符改成大写,第二个字符是将每个单词的第一个字符转成大写>>> print 'hello world!'.capitalize()Hello world!>>> print 'hello world!'.title()Hello World!讨论:写一个iscapitalized(s)函数,来判断字符串是不是首字符大写>>> 阅读全文

posted @ 2013-10-24 22:34 七海之风 阅读(164) 评论(0) 推荐(0)

导航