易截截图软件、单文件、免安装、纯绿色、仅160KB

Python入门的36个例子——04 优雅的字符串

# 004
# 利用三引号(''' or """)可以指示多行字符串
print '''line1
line2
line3'''
# 另外,你还可以在三引号中任意使用单引号和双引号
print ''' "What's up? ," he replied.'''
# 否则,你好使用转义符来实现同样的效果
# 还是使用三引号好,不然就破坏了视觉美了
print ' \"What\'s up? ,\" he replied.'
# 你可以使用raw(r)(原始字符串)来消除转义字符的转义功能
print r' \"What\'s up? ,\" he replied.'
# 单引号和双引号的全等性似乎意味着Python中没有“char”这个概念
# 事实正是如此!
# “char”是为机器服务的(The genesis of the computer revolution was in a machine. The genesis of our programming languages thus tends to look like that machine.)
# 而Python是为程序员服务的

output:
1
2
3
4
5
6
line1
line2
line3
 "What's up? ," he replied.
 "What's up? ," he replied.
 \"What\'s up? ,\" he replied.


相关文档:

python类型转换,数值操作(转)


http://hi.baidu.com/guzhilei1986/blog/item/8969b4debe99e150ccbf1ae7.html
函数                       描述  
int(x [,base ])          ......

python自动补全以及自带脚本运行失败解决方法

python的自动补全有很多方法,本质上都是用字典。生成字典最常用的当然是ctag了,但是每次增加模块都要ctag一次也挺麻烦的。
能偷懒的是后偷懒是一种美德,有人已经做了字典和增加模块的脚本,我们干嘛不坐享其成呢。
http://vim.sourceforge.net/scripts/script.php?script_id=850
这个名为pydiction的项目包括了一个字 ......

Python Re

1. Basic
参考《Python正则表达式操作指南》 
模块re,perl风格的正则表达式
regex并不能解决所有的问题,有时候还是需要代码
regex基于确定性和非确定性有限自动机
2. 字符匹配(循序渐进)
元字符
. ^ $ * + ? { [ ] \ | ( )
1) "[" 和 "]"常用来指定一个字符类别,所谓字符类别就是你想匹配的一个字符集。如[ ......

easy_install让python的包管理变得easy

Python中的easy_install工具很好用,它的作用类似于Php中的pear,或者Ruby中的gem,或者Perl中的cpan。
如果想使用easy_install工具,可以直接安装ez_setup.py
脚本,再python ez_setup.py(之前先要安装python):
安装完后,最好确保easy_install所在目录已经被加到PATH环境变量里:
Windows: C:\Python25\Scripts
Li ......

python运算符 供重载参考

二元运算符及其对应的特殊方法
二元运算符
特殊方法
+
__add__,__radd__
-
__sub__,__rsub__
*
__mul__,__rmul__
/
__div__,__rdiv__,__truediv__,__rtruediv__
//
__floordiv__,__rfloordiv__
%
__mod__,__rmod__
**
__pow__,__rpow__
<<
__lshift__,__rlshift__
>>
_ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号