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

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 布尔或


相关文档:

用python连接mysql数据库


#
-*- encoding: gb2312 -*-
import
os, sys, string
import
MySQLdb
#
连接数据库
try
:
conn
=
MySQLdb.connect(host
=
'
localhost
'
,user
=
'
root
'
,passwd
=
'
xxxx
'
,db
=
'
test1
'
)
except
Exception, e:
print
e
sys.exit()
......

Python: python的简单表达式计算器

这是一个简单的表达式计算器, 不太懂用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 ......

Python 有权重的随机选择, Weighted Random Choice

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])
   ......

scite python API

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

Python 3 教程一:入门

Python已经是3.1版本了,与时俱进更新教程.
本文适合有Java编程经验的程序员快速熟悉Python
本文程序在windows xp+python3.1a1 测试通过.
本文提到的idle指python shell,即安装python后你在菜单看到的IDLE(python gui)
在idle里ctrl+n可以打开一个新窗口,输入源码后ctrl+s可以保存,f5运行程序.
凡打开新窗口即指ctrl ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号