易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : Python

Python入门的36个例子 之 35

源代码下载:下载地址在这里
# 039
while True:
try:
x = int(raw_input('Input a number:'))
y = int(raw_input('Input a number:'))
z = x / y
except ValueError, ev:
print 'That is not a valid number.', ev
except ZeroDivisionError, ez:
print 'Divisor is zero:', ez
except:
print 'Unexpected error.'
raise
else:
print 'There is no error.'
break
# end of try
# end of while
print x,'/',y,'=',x/y

output:
Input a number:w
That is not a valid number. invalid literal for int() with base 10: 'w'
Input a number:9
Input a number:0
Divisor is zero: integer division or modulo by zero
Input a number:9
Input a number:3
There is no error.
9 / 3 = 3 ......

Python入门的36个例子 之 36

# 040
import time
try:
f = file('040_Finally.py')
while True:
line = f.readline()
if len(line) == 0:
break
time.sleep(0.33)
print line,
# end of while
finally:
f.close()
print 'Closed the file.'
# end of try
output:
>>>
# 040
import time
try:
    f = file('040_Finally.py')
    while True:
        line = f.readline()
        if len(line) == 0:
            break
        time.sleep(0.33)
        print line,
    # end of while
finally:
    f.close()
    print 'Closed the file.'
# end of try
   
Closed the file.
>>>
源代码下载:下载地址在这里
......

穿越Python Challenge

 第九关 Image
    从页面上的图片可以看到有一串点,那么是不是代表该关与图像点有关? 我们从页面源码可以看到,有两段数字序列first和second,而有一个提示first+second=? 什么意思呢?难道是说(first, second)代表了图像点的坐标?不像,两段序列的长度有很大差异。那么算符+还有什么含义呢,有可能是将两段序列拼起来,然后每两个数字代表一个图像点。通过处理,我们在原图片上按照给定的坐标涂黑点,却发现什么都看不清;因此我们按照图片的规格新建一个图片,在黑底上涂白点,处理程序如下:
#!/bin/python
# file: good.py

import re, Image

file = open('d:\Python\good.html')
message = re.findall('(<!--[^-]+-->)', file.read(), re.S)[1]
file.close()

first = re.findall('(\d+)',re.findall('first:(.+)second',message,re.S)[0],re.S)
second = re.findall('(\d+)',re.findall('second:(.+)>',message,re.S)[0],re.S)

all = first + second

im = Image.open('d:\Python\good.jpg')
im2 = Image.new(im.mode, im.size)

for x in range(0,len(all),2):
im2.putpixel((int(all[x]),int(a ......

python 练手


可以播放大部分的音视频.
demo download:  http://www.sandy1219.com/python/media.rar
playMP3.py
# -*- coding: utf-8 -*-
import wx;
import wx.media;
import os;
import SPrint;
import mediaStateBar;
import mediaList;
import SaveLog;
import MediaItem;
woldcart = "media files|*.*|avi|*.avi|rmvb|*.rmvb|rm|*.rm|wma|*.wma|mp3|*.mp3";
class MediaFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,wx.NewId(),u"媒体播放器",pos=wx.DefaultPosition,size=(500,500));
self.media = '';
try:
self.media = wx.media.MediaCtrl(self,style=wx.SIMPLE_BORDER,
#szBackend=wx.media.MEDIABACKEND_DIRECTSHOW
#szBackend=wx.media.MEDIABACKEND_QUICKTIME
#szBackend=wx.media.MEDIABACKEND_WMP10
);
self.media.Bind(wx.media.EVT_MEDIA_LOADE ......

在Windows上安装Python+MySQL 的常见问题及解决方法

验证是否已经安装了MySQLdb:
==========================================================
d:\usr\local\Python25>python
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] onwin32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
==========================================================
如果有类似于上面的"No module named MySQLdb",表明MySQLdb尚未安装或安装的不成功!
MySQL 版本:5.0.67
下载地址:http://dev.mysql.com/downloads/mysql/5.0.html#downloads
下载exe文件并安装
==========================================================
Python 版本:2.5
下载地址:http://www.python.org/download/releases/2.5.4/
下载msi文件并安装
MySQLdb版本: MySQLdb Windows binary for Python 2.5
下载地址:http://biohackers.net/wikiattach/Py ......

linux操作系统安装python3

首先是下载python3,现在的最高版本是3.1.1
for linux。
我的放置路径是/home/python下放置Python-3.1.1.tgz,执行以下系列操作:
1.解压:tar zxvf Python-3.1.1.tgz----生成解压包Python-3.1.1
2.转换到Python-3.1.1路径下,执行./configure
3.make
4.make install
在rehl5中已经默认安装了python2.4,所以要做如下操作:
#cd /usr/bin
#ll |grep python   //查看该目录下python
#rm -rf python
#ln -s PREFIX/
Python-3.1.1/python ./python  //PREFIX为你解压python的目录
#python
检测改正之后的python版本 ......

linux操作系统安装python3

首先是下载python3,现在的最高版本是3.1.1
for linux。
我的放置路径是/home/python下放置Python-3.1.1.tgz,执行以下系列操作:
1.解压:tar zxvf Python-3.1.1.tgz----生成解压包Python-3.1.1
2.转换到Python-3.1.1路径下,执行./configure
3.make
4.make install
在rehl5中已经默认安装了python2.4,所以要做如下操作:
#cd /usr/bin
#ll |grep python   //查看该目录下python
#rm -rf python
#ln -s PREFIX/
Python-3.1.1/python ./python  //PREFIX为你解压python的目录
#python
检测改正之后的python版本 ......
总记录数:695; 总页数:116; 每页6 条; 首页 上一页 [100] [101] [102] [103] 104 [105] [106] [107] [108] [109]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号