# -*- coding:utf-8 -*-

##s.partition(d)
##Searches string s for the first occurrence of some delimiter string d.if s contains
##the delimiter,it returns a truple(pre,d,post),where pre is the part of s before
##the delimiter ,d is the delimiter itself,and post is the part of s after the delimiter.

##s=u'平林漠漠烟如织,寒山一带伤心碧。暝色入高楼,有人楼上愁。玉阶空伫立,宿鸟归飞急。何处是归程?长亭更短亭'
##
##print '------转换成GBK的显示方式---'
##print s.encode('GBK')
##print '-----原始编码----'
##print s
##
##li=s.partition(u',')
##
##print u'----显示元组----'
##
##print li
##
##print '----显示元组中的单个元素----'
##for i in li:
## print i.encode('GBK')
##
##s.replace(old,new[,max])
##Return a copy of s with all occurrences of string old replaced by string new.
##Normally,all occurrence are replaced;if you want to limit the number of replacements,
##pass that limit as the max argument.
##
##print 'banana'.replace('a','###')
##
##s.rfind(t[,start[,end]])
##like .find(),but if t occurs in s,this method returns the highest starting index.
##
##print 'banana'.find('a')
##print 'banana'.rfind('a')
##
##s.rindex(t[,start[,end]])
##Similar to s.index(),but it returns the last index in S where string t is found.
##It will raise a valueError exception if the string is not found.
##

##print 'banana'.index('a')
##print 'banana'.rindex('a')
##
##print 'banana'.index('c')
##
##print 'banana'.rindex('c')

##s.rjust(w[,fill])
##Return a copy of s right-justified in a field of width w,padded with spaces.
##if w<=len(s),the result is a copy of s.
##
##To pad values with some character than a space,pass that character as the optional second argument.

##print '123'.rjust(5)
##
##print '123'.rjust(5,'*')
##
##s.rpartition(d)
##Similar to s.partition(),except that it finds the last occurrence of the delimiter.
##s.rsplit(d[,max])
##Similar to s.split(d[,max]),except that if there are more fields than max,the split
##fields are taken from the end of the string instead of from the beginning.
##s.rstrip([c])
##Return s with all trailing characters from string c removed.The default value for c
##is a string containing all the whitespace characters.
##
##s.split(d[,max])
##Returns a list of strings [s1,s2,...] made by splitting s into pieces wherever the
##delimiter string d is found.The default is to split up s into pieces wherever clumps
##of one or more whitespace characters are found.
##The optional max argument limits the number of pieces removed from the front of s.
##The resulting list will have no more than max+1 elements.
##To use the max argument while splitting the string on clumps of whitespace,pass none
##as the first argumet.

##s =u'花非花,雾非雾。夜半来,天明去。来如春梦几多时。去似朝云无觅处。'
##
##for i in s.split(u'。'):
## print i.encode('GBK')
##print 'We are ready to use the max arguments'
##
##for i in s.split(u'。',2):
## print i.encode('GBK')

##s.splitlines([keepends])
##Splits s into lines and returns a list of the lines as strings.Discards the line
##sparators unless the optional keepends arguments is true.

##s=u'''江南好,
##风景旧曾谙。
##日出江花红胜火,
##春来江水绿如蓝。
##能不忆江南。'''
##
##print s.splitlines()
##for i in s.splitlines():
## print i.encode('GBK')

##s.startswith(t[,start[,end]])
##Predicate to test whether s starts with string t.Otherwise similar to .endswith().
##s.strip([c])
##Return s with all leading and trailing characters from string c removed.The default
##value for c is a string containing all the whitespace characters.

##s =u' 江南好, 风景旧曾谙。 日出江花红胜火, 春来江水绿如蓝。 '
##print s.strip()
##print s.strip(u',')

##s.swapcase()
##Return a copy of s with each lowercase character replaced by its uppercase equivalent,
##and vice versa.

##print 'abcDEV'.swapcase()

##s.upper()
##Return a copy of s with all lowercase characters replaced by their uppercase equivalents.

##s.zfill(w)
##Return a copy of s left-filled with '0' characters to width w.

## --- Type unicode: Strings of 32-bit character ---

##To get a Unicode string,prefix the string with u .
##All the operators and methods of str type are available with unicode values.
##Addititonally,for a Unicode value u,use this method to encode its value as a string of type str
##
##To encode a Unicode string U,use this method:
## U.encode('utf-8')
##
##To decode a regular str values S that contains a UTF-8 encoded value,use this method:
## S.decode('utf-8')

##>>>u16 = u'\u0456'
##>>>u16
##>>>s = u16.encode('Utf-8')
##>>>s
##

## --- Type list:Mutable sequences ---
##There are a number of functions that can be used with lists as well:
## all():Are all the elements of an iterable true?
## any():Are any of the members of an iterable true?
## cmp():Compare two values
## enumerate():Step through indices and values of an iterable
## filter():Extract qualifying elements from an iterable
## iter():Produce an iterator over a sequence
## len():Number of elements
## list():Convert to a list
## map():Apply a function to each element of an iterable
## max():Largest element of an iterable
## min():Smallest element of an iterable
## range():Generate an arithmetic progression as a list
## reduce():Sequence reduction
## reversed():Produce a reverse iterator
## sorted():Sort a sequence
## sum():Total the elements of a sequence
## xrange():Arithmetic progression generator
## zip():Combine multiple sequences
##
##

##Methods on lists
##For any list value Li,these methods are available.
##Li.append(X):Append a new element x to the end of list Li.Does not return a value.
##Li.count(x):Return the number of elements of Li that compare equal to x.
##Li.extend(s):Append another sequence s to Li
##Li.index(x[,start[,end]]):
## If Li contains any elements that equal x,return the index of the first such element,otherwise
## raise a valueError exception.
## The option start and end arguments can be used to search only positions
## with the slice Li[start:end]
##
##Li.insert(i,x):Insert a new element x into list Li just before the ith element,
##shifting all higher-number elements to the right.No value is returned.

##Li.pop([i])
##Remove and return the element with index i from Li.The default value for i is -1,
##so if you pass no argument,the last element is removed.
##Li.remove(x)
##Remove the first element of Li that is equal to x.If there are not any such elements,
##raises ValueError.
##Li.reverse(): Reverses the elements of Li in place.Does not return a result.

##Li.sort(com[,key[,reverse]]])
##Sort list Li in place.Does not return a result.
##The reordering is guaranteed to be stable--that is,if tow elements are considered equl,
##their order after sorting will not change.

## --- Types set and frozenset:set types ---
##Mathematically speaking ,a set is an unordered collection of zero or more distinct elements.
##Most operations on sets work with both set and frozenset types.
##Values of type set are mutable:you can add or delete members.
##There are two ways to create a mutable set.
##In all python version of the 2.x series,the set(S) function operates on a sequence S and returns
##a mutable set containing the unique elements of S. The arguments is optional;if omitted,
##you get a new , empty set.

##Li = [1,3,5,3,3,5,5,9,8,8,0]
##s1 = set(Li)
##s2 = set()
##s3 = set('notlob bolton')
##print Li,len(Li)
##print s1,len(s1)
##print s2,len(s2)
##print s3,len(s3)

##A frozenset value is immutable:you can not change the membership,but you can use
##a frozenset value in contexts where set values are not allowed. For example,you can
##use a frozenset as a key in a dictionary ,but you cant not use a set values
##as a dictionary key.

--- Type dict:Dictinonaries ---
Python dictionaries are one of its more powerful built-in types.They are generally
used for look-up tables and many similare applications.

A Python dictionary represents a set of zero or more ordered pairs(ki,vi) such that:
Each k value is called a key;
Each key is unique and immutable;
and the associated value vi can be of any type.
Another term for this structure is mapping ,since it maps the set of keys onto the set
of values (in the algebraic sense).

Operations on dictionaries
These operations are available on any dictionary object D:
len(D):returns the number of key-value pairs in D.
D[k]: If diactionary D has a key whose value is equal to K,this operation
returns the corresponding value for that key.If there is no matching key,
it raises a KeyError exception.
D[k] = v : If dictionary D dose not have a key-value pair whose key equals k,
a new pair is added with key k and value v.
If D already has a key-value pair whose key equals k,the value of that pair is replaced by v.
k in D : A predicate that tests whether D has a key equal to k.
k not in D: A predicate that tests whether D does not have a key equal to k.
del D[k]: In Python ,del is a statement ,not a function;If dictionary D has a
key-value pair whose key equals k,that key-value pair is deleted from D. If there
is no matching key-value pair,the statement will raise a KeyError exception.
D.get(k,x):If dictionary D has a key equal to x,it returns the corresponding value,
that is ,it is the same as the expression "D[x]".

python27读书笔记0.2的更多相关文章

  1. python27读书笔记0.3

    #-*- coding:utf-8 -*- ##D.has_key(k): A predicate that returns True if D has a key k.##D.items(): Re ...

  2. python27读书笔记0.1

    --Notes: 测试环境:Windows ,python 2.7.3,python 自带的IDLE #-*- coding: utf-8 -*- # First Lesson# --- Line s ...

  3. 驱动开发学习笔记. 0.06 嵌入式linux视频开发之预备知识

    驱动开发读书笔记. 0.06  嵌入式linux视频开发之预备知识 由于毕业设计选择了嵌入式linux视频开发相关的项目,于是找了相关的资料,下面是一下预备知识 UVC : UVC,全称为:USB v ...

  4. 驱动开发学习笔记. 0.05 linux 2.6 platform device register 平台设备注册 2/2 共2篇

    驱动开发读书笔记. 0.05 linux 2.6 platform device register 平台设备注册 2/2 共2篇 下面这段摘自 linux源码里面的文档 : 内核版本2.6.22Doc ...

  5. 驱动开发学习笔记. 0.04 linux 2.6 platform device register 平台设备注册 1/2 共2篇

    驱动开发读书笔记. 0.04  linux 2.6 platform device register 平台设备注册  1/2 共2篇下面这段摘自 linux源码里面的文档 : Documentatio ...

  6. 驱动开发学习笔记. 0.02 基于EASYARM-IMX283 烧写uboot和linux系统

    驱动开发读书笔记. 0.02 基于EASYARM-IMX283 怎么烧写自己裁剪的linux内核?(非所有arm9通用) 手上有一块tq2440,但是不知道什么原因,没有办法烧boot进norflas ...

  7. 驱动开发学习笔记. 0.01 配置arm-linux-gcc 交叉编译器

    驱动开发读书笔记. 0.01 配置arm-linux-gcc 交叉编译器 什么是gcc: 就像windows上的VS 工具,用来编译代码,具体请自己搜索相关资料 怎么用PC机的gcc 和 arm-li ...

  8. 【英语魔法俱乐部——读书笔记】 0 序&前沿

    [英语魔法俱乐部——读书笔记] 0 序&前沿   0.1 以编者自身的经历引入“不求甚解,以看完为目的”阅读方式,即所谓“泛读”.找到适合自己的文章开始“由浅入深”的阅读,在阅读过程中就会见到 ...

  9. 《玩转Django2.0》读书笔记-探究视图

    <玩转Django2.0>读书笔记-探究视图 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 视图(View)是Django的MTV架构模式的V部分,主要负责处理用户请求 ...

随机推荐

  1. 可视化swing界面编辑--转载

    原文地址:http://279234058.iteye.com/blog/2200122 今天发现了一个WindowBuilder插件,功能好强大,啊哈哈,从此告别手动编辑swing界面代码,直接像V ...

  2. 可扩展的listview--Expandablelistview

    layout.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" x ...

  3. mysql的数据导入导出

    1.Navicat for Mysql XML导出导入格式支持二进制数据:虽然同步数据人眼看不出区别,但是java尝试读取数据时,报datetime字段取出的值为“0000-00-00 00:00:0 ...

  4. about semget

    flags must include read,write,execute permission. for examples: semget( 3333, 1, IPC_CREAT | IPC_EXC ...

  5. Flume简介与使用(三)——Kafka Sink消费数据之Kafka安装

    前面已经介绍了如何利用Thrift Source生产数据,今天介绍如何用Kafka Sink消费数据. 其实之前已经在Flume配置文件里设置了用Kafka Sink消费数据 agent1.sinks ...

  6. javascript优化工具 Doloto

    Doloto是“Download Time Optimizer”的简写.官方页面上说它对于大型复杂的AJAX应用尤其的有用,因为这些应用包含了大量的 JavaScript 代码.简单的说,它的工作原理 ...

  7. 获取iframe 内元素的方法

    1,原生的方法 首先给iframe 设置 id 属性 var obj = document.getElementById('iframe').contentWindow; setTimeout(fun ...

  8. smarty中的变量使用

    在模板中输出动态数据可以用{},所以容易与css中的标签相互冲突,所以使用{literal}{/literal}标签包起来就不会用模板的解析方式解析,变量的来源有三种,用assign方法赋值,系统保留 ...

  9. NC参照查那个表

    select * from bd_refinfo where name like '%人员工作记录全职树(行政树)%';select * from bd_refinfo where name like ...

  10. 第六章 jQuery操作表单

    1.单行文本框的应用 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ...