巴扎黑
浏览量11658 | 粉丝242 | 关注1
2016-12-09 11:41:41
判断一字符串是否对称,如:abccba
# 1.判断一字符串是不是对称的,如:abccba def is_symmetrical(str): length = len(str) for index in range(length / 2): if str[index] == str[length - index - 1]: pass else: return False return ...
6211
2016-12-09 11:43:01
用wxpython写的一个天气预报
自学了半个多月python和wx,想写个天气预报练练手,可是写的时候遇到了很多问题,非常纠结,索性把东西上传给各位看看。东西很简单,就几十行代码� ...
1751
2016-12-09 11:49:50
Python map、filter,reduce介绍
1、filter(function,iterable) 引用Construct a list from those elements of iterable for which function returns true. iterable may be either a sequence, a container which supports iteration, or an iterator. ...
1459
2016-12-09 13:25:01
redis-python
#!/usr/bin/env python #coding=utf-8 import os import sys print 'python redis ' import redis import redis r = redis.StrictRedis(host='127.0.0.1', port=6379,db = 4) r.set('one', 'hello') print r.get('one ...
1338
2016-12-09 13:27:14
python tips
1、enum #!/usr/bin/env python # -*- coding:utf-8 -*- def enum(**enums): return type('Enum', (), enums) Gender = enum(MALE=0,FEMALE=1) print Gender.MALE print Gender.FEMALE 2、检查字符串是否是number ...
2816
2016-12-09 13:31:33
python decorators
Contains: 1、decorators 2、functools 首先我们看下tornado中使用的装饰器 1、@tornado.web.authenticated 引用Decorate methods with this to require that the user be logged in. def authenticated(method): ""& ...
1474
2016-12-09 13:35:20
Python异步网络探
异步网络据说能极大的提高网络server的连接速度,所以打算写一个专题,来学习和了解异步网络.因为Python有个非常出名的异步Lib:Twisted,所以就用Python来完成. OK,首先写一个pythone socket的server段,对开放三个端口:10000,10001,10002.krondo的例子中是每个server绑定一个端口,测试的时候需要分别开3个shell,分别运行.这太麻烦 ...
1702
2016-12-09 13:41:02
python内存释放原则
def getInit(class_name): """动态加载模块""" resultmodule = __import__(class_name, globals(), locals(), [class_name]) resultclass = getattr(resultmodule, class_n ...
1541
2016-12-09 13:47:10
排序算法学习之冒泡排序
冒泡排序(Bubble Sort,台灣譯為:泡沫排序或氣泡排序)是一種簡單的排序算法。它重複地走訪過要排序的數列,一次比較兩個元素,如果他們的順序錯誤就把他們交換過來。走訪數列的工作是重複地進行直到沒有再需要交換,也就是說該數列已經排序完成。這個算法的名字由來是因為越小的元素會經由交換慢慢「浮」到數列的頂端。冒泡排序演算法的運作如下: 1. 比較相鄰的元素。如果第一個比第二個大,就交換他們兩個。 ...
1703
2016-12-09 13:50:51
python中获取python版本号的方法
最近在思考如何使用python做自动化测试的问题,没啥进展。感觉国内自动化测试ruby用的比较多,目前想做一件事就是如何用python来测试web程序,包括web的页面检查。在大型企业架构中单元测试是一个很重要的概念,这个概念在后端代码中很普及,但是前端JS中做单元测试不是很常见,不知python能否在这个地方发挥用处,目前可以使用python来做接口测试。今天有同学问我怎么在python中 ...
1587