--Notes:

测试环境:Windows ,python 2.7.3,python 自带的IDLE

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

# First Lesson
# --- Line syntax ---
# The comment character is "#" ;comments are terminated by end of line.
# Long lines may be continued by ending the line with a backslash(\).

# --- Names and Keywords ---
# Python names(also called identifiers) can be any length and follow these rules:
# 1.The first or only character must be a letter(uppercase or lowercase) or the underbar character,"_".
# 2.Any additional characters may be letters,underbar,or digits.
# 3.Case is significant in Python. The name "Robin" is not the same name as "robin".
#
# The names below are keywords,also known as reserved words.They have special meaning in Python
# and cannot be used as names or identifiers.
#
# and as assert break class continue def del elif else except exec finally for from global
# import if in is lambda not or pass print raise return try with while yield
#

# --- Python's common types ---
# int : 3; long: 3L ; bool: True,False; float : 3.1425
# complex :(3.2+4j) ; str :'string'; unicode :u'Fred';
# list :[] ; tuple:(); dict:{}; bytearray('Bletchley')
# file open('/etc/motd')
#

# To write a long-type constant ,use the same syntax as for int-type constants,
# but place a letter L immediately after the last digit.Also, if an operation on
# int values results in a number too large to reparesent as an int, Python will
# automatically converted it to type long.

#page 16

# --- Methods on Str values ---
##These methods are availabe on any string value S.
##S.capitalize()
##Return S with its first character capitalized(if a letter).
##print 'e e cummings'.capitalize()
##print '2 e 3cummings'.capitalize()
##print 'word in cummings'.capitalize()

##S.center(w)
##Return S centered in a string of width w,padded with spaces.
##If w<=len(S),the result is a copy of S. If the number of padding is
##odd ,the extra space will placed after the centered value.

##print 'x'.center(4)
##print 'x'.center(5)
##print 'capitalize'.center(4)

##S.count(t[,start[,end]])
##Return the number of times string t occurs in S. To search on a
##slice S[start:end] of S,supply start and end arguments.

##print 'banana'.count('a')
##print 'banana'.count('na')
##print 'banana'.count('a',3)
##print 'banana'.count('a',3,5)
##print '中华人民共和国'.count('民')
##print '黄山落叶松叶落山黄'.count('黄')

##S.decode(encoding)
##If S contains an encodedd Unicode String ,this method will return the corresponding
##value as unicode type. The encoding argument specifies which decoder to use;
##typically this will be the string 'utf_8' for the UTF-8 encoding.

##s=u'banana';
##print s.decode('utf-8')
##print s.decode('gbk')
##print s.decode('GBK')

##S.endswith(t[,start[,end]])
##Predicate to test whether S ends with String t.If you supply the optional start
##and end arguments,it tests whether the slice S[start:end] ends with t.

##s='落霞与孤鹜齐飞,秋水共长天一色'
##print s.endswith('秋水')
##print s.endswith('色')
##print s.endswith('一色')
##print s.endswith('秋水共长天一色')
##print s
##print s[1:7]
##print s.endswith('齐飞',1,7)
##s='Python is not su grace!'
##print s
##print s[1:9]
##print s.endswith('is',1,9)
##
##输出:
##False
##True
##True
##True
##落霞与孤鹜齐飞,秋水共长天一色
##惤闇炰
##False
##Python is not su grace!
##ython is
##True

##s.expandtabs([tabsize])
##Returns a copy of s with all tabs repalced by one of more spaces.
##Each tab is interpareted as a request to move to the next "tab stop".
##The optional tabsize argument specifies the number of sapces
##between tab stops;the defualt is 8.

##s.find(t[,satrt[,end]])
##If string t is not found in S,return -1; otherwise return the index of the
##first position in s that matches t.
##The optional start and end arguments restrict the search to slice s[start:end].

##s.index(t[,start[,end]])
##Works like .find(),but if t is not found,it raise a ValueError exception.

##s.isalum()
##predicate that tests whether S is nonempty and all its characters are alphanumeric.
##s.isalpha()
##Predicate that tests whether s is nonempty and all its characters are letters.
##s.isdigit()
##Predicate that tests whether s is nonempty and all its characters are digits.
##s.islower()
##Predicate that tests whether s is nonempty and all its letters are lowercase
##(non-letter characters are ignored).
##s.isspace()
##Predicate that tests whether s is nonempty and all its characters are whitespace characters.
##' \t\n\r'.isspace()
##s.istitle()
##A predicate that tests whether s has "title case".
##s.isupper()
##Predicate that tests whether s is nonempty and all its letters are uppercase letters
##(non-letter cahr-acters are ignored).

s.join(L)
L must be an iterable that produces a sequence of strings.The returned value is a string
containing the members of the sequence with copies of the delimiter string s inserted between them.
s.ljust(w)
Return a copy of s left-justified in a field of width w,padded with spaces.If w<=len(s),
the result is a copy of s.
s.lower()
Returns a copy of S with all uppercase letters replaced by their lowercase equivalent.
s.lstrip([c])
Return s with all leading characters from string c removed.The default value for c is a string
containing all the whitespace characters.

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

  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.2

    # -*- coding:utf-8 -*- ##s.partition(d)##Searches string s for the first occurrence of some delimite ...

  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. win7(64bit)python相关环境模块搭建

    包括Python,eclipse,jdk,pydev,pip,setuptools,beautifulsoup,pyyaml,nltk,mysqldb的下载安装配置. **************** ...

  2. (转) 如何在JavaScript与ActiveX之间传递数据1

    本文研究如何在JS等脚本语言与ActiveX控件之间通信,如何传递各种类型的参数,以及COM的IDispatch接口.使用类似的方法,可以推广到其他所有脚本型语言,如LUA,AutoCad等.本文将研 ...

  3. 句柄(Handle)

    1.句柄是什么?    在windows中,句柄是和对象一一对应的32位无符号整数值.对象可以映射到唯一的句柄,句柄也可以映射到唯一的对象.2.为什么我们需要句柄?     更准确地说,是window ...

  4. javascript笔记01:javascript入门介绍

    javascript是实现网页动态效果的基石,在web开发中扮演重要的角色,被广泛应用的各个领域 (1)网页游戏 (2)地图搜索 (3)股市信息查询 (4)web聊天 …………

  5. 将CGPoint、CGSize、CGRect等放进数组的方法

    在oc中,数组中只能存放NSObject类型的数据,所以如果将CGPoint.CGSize.CGRect这些数据存到数组中,我们需要将他们转换为对象类型才可以, 可以借助NSValue,它是用来将基本 ...

  6. APUE(3)——文件I/O

    大多数情况下,我们都会利用Standard I/O Library来进行I/O操作,而这一章所讲的I/O是UNIX系统直接提供的I/O操作,且大多是Unbuffered I/O,即每一次读或写都会出现 ...

  7. Flash cs6 如何从FLA 文件导出sound文件

    Flash. How to export sound from the FLA file extract sound from a fla 第一个是图文教程,在下面还有"watch vide ...

  8. 使用Keil建立工程和烧录到89C52板上

    又开始学习C51了,不清楚能坚持多久,之前学过一段时间,学完P1口就没再学了,之前学的都忘了. 1. 使用Keil 进行建立工程:打开Keil 4. 加载C文件进工程里面 然后展开"Sour ...

  9. [转]Markdown 11种基本语法

    Markdown 11种基本语法 现在是我在学习Markdown时做的笔记.学完这些Markdown的基本使用已经不成问题. 1. 标题设置(让字体变大,和word的标题意思一样) 在Markdown ...

  10. C++多态性与C#的比较

        多态性:统一操作作用于不同的对象可以有不同的解释,产生不同的执行结果.多态性可以分为两种:一是编译时的多态性,一是运行时的多态性.     编译时的多态性包括重载.覆盖.运算符重载.对于非虚的 ...