# -*- 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. 我的开发框架(WinForm)3

    今天继续给大家介绍核心库的IOC的使用,在我的框架里,IOC使用的比较简单,主要是用于解除模块间的耦合和实例化接口. 1.接口说明,IocContainer接口比较简单只有3个方法,但是是系统中用的最 ...

  2. [转]使用ADO.NET访问Oracle存储过程

    本文转自:http://www.cnblogs.com/datasky/archive/2007/11/07/952141.html 本文讨论了如何使用 ADO.NET 访问 Oracle 存储过程( ...

  3. 用CentOS 7打造合适的科研环境

    http://seisman.info/linux-environment-for-seismology-research.html 这篇博文记录了我用CentOS 7搭建地震学科研环境的过程,供我个 ...

  4. 自己写http获取网络资源和解析json数据

    虽然github上有很多开源的,方便的jar报,用起来也很方便,但我们也需要了解其中的原理,如何自己不用第三方jar包来获取网络资源 主要代码如下:  因为联网是耗时的操作,所以需要另开一个线程来执行 ...

  5. aspjpeg 半透明描边的实现函数

    '参数说明 'big 原图路径(相对) 'small 生成图路径(相对) 'width_s 生成后宽度(数值型) 'height_s生成后高度(数值型) 'images/Alpha.jpg 为一个像素 ...

  6. Linux下如何查看哪些端口处于监听状态

    查看某一端口的占用情况: lsof -i:端口号 前提:首先你必须知道,端口不是独立存在的,它是依附于进程的.某个进程开启,那么它对应的端口就开启了,进程关闭,则该端口也就关闭了.下次若某个进程再次开 ...

  7. AlwaysOn实现只读路由

    1.配置只读路由 ①配置A副本的只读路由属性(ReadOnly代表‘只读意向’) ALTER AVAILABILITY GROUP [testAG] MODIFY REPLICA ON N'WIN-1 ...

  8. Linux中的版本控制---diff和patch命令

    一.构造两个用于测试的文件 hello.txt: world.txt: 二.用diff命令比较两个文本文件的差异 对这个两个文本文件执行diff‘命令,并通过输出重定向,将差异保存在diff.txt文 ...

  9. ios面试题集锦(一)

    一.前言部分 文中的问题多收集整理自网络,不保证100%准确,还望斟酌采纳. 1.iOS9有哪些新特性? 答案: 1)改进了 Siri 基于日期.位置和相簿名称来搜索个人照片和视频 要求 Siri 来 ...

  10. OC6_类方法

    // // Dog.h // OC6_类方法 // // Created by zhangxueming on 15/6/9. // Copyright (c) 2015年 zhangxueming. ...