Python 基础 1
1.解释性 可以直接从源代码运行程序.在计算机内部,Python解释器把源代码转换成称为字节码的中间形式,然后再把它翻译成计算机使用的机器语言并运行.
2.#符号后面的内容都是注释.
3.在字符串中行末的'\'表示下一行的内容和上一行是接着的;字符串前加一个r表示某些不需要转义符那样的特别处理的字符串;在处理文本文件的时候使用 Unicode字符串,特别是这个文件中包含有用非英语的语言写的文本;一定要用自然字符串表示正则表达式,不包括 char这个类型.
4.基本的数据类型包括数和字符串.数的类型包括:四类, 整数,长整数,浮点数和复数.
5.使用变量时,只需赋值给他们即可.
6.在逻辑行首的空白用来决定逻辑行的缩进层次,从而用来决定语句的分组.
7.运算符:'a'+'b'='ab','la'*3='lalala',3**4表示3的4次幂,//:取整除,%:取模,大于小于号可以任意连接,==比较对象是否相等,not 表示布尔非,and 布尔与,or 布尔或
相关文档:
赖勇浩(http://laiyonghao.com)
今天(2009年5月31日) OurPNP.org 搞了个聚会活动,弄了十几二十个人在广州海珠广场的堂会呆了五个小时,创下了我在 K 房呆的最长时间纪录。应他们的邀请,我做了个题为《用 python 快速搭建网游服务器》的小演讲,因为那边的电视竟然不能接电脑,所以讲的时候没有能够参照 PPT 来讲,观 ......
multiprocessing — Process-based “threading” interface
Introduction
multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers both local and remote concurrency, effectively side-stepping the Glo ......
这是一个简单的表达式计算器, 不太懂用Tkinter写GUI, 参考了别人的代码
from __future__ import division
from Tkinter import Tk, Entry, Button, Label, mainloop
from tkFont import Font
def get_value ():
v = ''
try:
v = eval(text.get()) #use eval to calculate the vlaue of the text
except:
pa ......
1.常用方法,不带参数
def decator(func):
def inner_func(*args):
args = (i * 2 for i in args)
return func(*args)
return inner_func
@decator
def add(a, ......
'''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. ......