今天有个简单的小需求:求列表中每个元素的个数,实现的方法有好几种,这里我就说一个用set来实现的。#!/usr/bin/envpython
fa=[1,2,3,4,5,3,2,1,1,1,1,1,1,3,3,3,3,3]
fb=set(fa)
foriinfb:
printi,fa.count(i)首先定义了一个列表,然后将列表使用set初始化之后赋值给fb,在..
分类:
编程语言 时间:
2014-08-22 18:13:49
阅读次数:
176
用惯了eclipse,这个轻量级的wingide还真是有点不适应不过看在它小的份上,自己动手吧我用的是4.01中文改个font就好edit->preferences->UserInterface在font/size的地方选个支持中文的我用的是这个nsimsun12,看着这个还算顺眼2自动补全edit->preferences->Editor-..
分类:
编程语言 时间:
2014-08-22 18:06:29
阅读次数:
1089
2014.08.22了解有关最新发布版本和相关工具的资讯,python.org网站就是一个聚宝盆。Windows安装:pythonx.x或activePythonPython是一种解释型的、面向对象的,带有动态语义的高级程序设计语言。Liunx,输入Python启动交互python解释器,Ctrl-D退出交互式解释器;1.Python一行..
分类:
编程语言 时间:
2014-08-22 18:05:39
阅读次数:
339
前段时间项目需要对某些图片打水印,用到Python的PIL库,本文以Imaging-1.1.7为例,记录PIL库的源码编译/安装步骤。
PIL全称Python Image Library,它支持多种图片格式的处理,能为我们的应用程序代理强大的图像处理能力,如裁剪、旋转、打水印等。
从官网下载v1.1.7版本源码并解压后,cd至解压目录,读README可知,若想在应用中处理jpeg图片,需要预先...
分类:
编程语言 时间:
2014-08-22 17:56:09
阅读次数:
278
Problem 35
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13,...
分类:
其他好文 时间:
2014-08-22 17:52:39
阅读次数:
185
http://www.crifan.com/python_auto_handle_cookie_and_save_to_from_cookie_file/#!/usr/bin/python# -*- coding: utf-8 -*-"""Function: 【整理】Python中Cookie的.....
分类:
编程语言 时间:
2014-08-22 17:45:29
阅读次数:
238
前段时间项目中碰到从windows机器上传多媒体文件至linux服务器的需求(人工审核并触发同步),调研了几种上传机制或实现方案:
1) http方式上传至WebServer
用PHP或Python脚本上传给WebServer,但由于多媒体文件动辄几百兆,PHP由于最长执行时间的限制首先被排除,另外由于用脚本上传需要增加失败重试等控制逻辑,Python虽然可以实现这些功能,但考虑到开发成本及服...
分类:
系统相关 时间:
2014-08-22 16:26:39
阅读次数:
283
Problem 32
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit
number, 15234, is 1 through 5 pandigital.
The produ...
分类:
其他好文 时间:
2014-08-22 16:23:19
阅读次数:
178
先看看python类的类变量和成员变量。见下面代码:
class TestClass(object):
val1 = 100
def __init__(self):
self.val2 = 200
def fcn(self,val = 400):
val3 = 300
self.val4 = val...
分类:
编程语言 时间:
2014-08-22 16:19:09
阅读次数:
193
Problem 33
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that49/98 = 4/8, which is correct, is obtained by cance...
分类:
其他好文 时间:
2014-08-22 16:17:19
阅读次数:
172