Python的操作符
1.#:注释符
2.比较运算符(基本和Java类似)
< <= > >= == != <>
Python目前支持两种"不等于"比较运算符,!=和<>,分别是C风格和ABC/Pascal风格。目前后者慢慢地被淘汰了,
推荐使用前者。
在Python中,支持3<4<5这样的表达式,既简洁又优美。它实际上是下面表达式的缩写:
3<4 and 4<5
建议:合理使用括号以增加代码的可读性
在很多场合使用括号都是是一个好主意。括号在Python中不是必须存在的,不过为了可读性,使用括号总是值得的。任何维护你代码
的人都会感谢你,在你再次阅读自己的代码时,你也会感谢你自己。
3.逻辑运算符
and or not
4.布尔型
True和False(首字母均为大写)
相关文档:
赖勇浩(http://laiyonghao.com)
今天(2009年5月31日) OurPNP.org 搞了个聚会活动,弄了十几二十个人在广州海珠广场的堂会呆了五个小时,创下了我在 K 房呆的最长时间纪录。应他们的邀请,我做了个题为《用 python 快速搭建网游服务器》的小演讲,因为那边的电视竟然不能接电脑,所以讲的时候没有能够参照 PPT 来讲,观 ......
这是一个我们在处理中文时, 经常遇到的问题.
python里面基本上要考虑三种编码格式
1 源文件编码
在文件头部使用coding声明。告诉python解释器该代码文件所使用的字符集。
#/usr/bin/python
#coding: utf8
2 内部编码
代码文件中的字符串,经过decode以后,被转换为统一的unicode格式的内部数据,类似于u'*'。unic ......
import random def windex(lst):
'''an attempt to make a random.choose() function that makes weighted choices
accepts a list of tuples with the item and probability as a pair'''
wtotal = sum([x[1] for x in lst])
......
'''gen_python_api.py generates a python.api file for SciTE
The generated api file includes
*) all Python keywords
*) all builtin functions
*) all module attributes
Module functions are represented by their docstring if available,
otherwise by the function definition from the source file. ......
http://code.google.com/p/shedskin/ Shed Skin 0.3 - support for 3 new standard library modules (now about 20 in total): - itertools (jeremie roquet) - heapq (jeremie roquet) - csv (converted using shedskin) - 4 new example programs (now 44 in total!): - maximum weighted matching al ......