python list的一个面试题】的更多相关文章

面试题''' 一个list,里面的数字偶数在左边,奇数在右边,不借助其他列表 ''' def userlist(add_list): if type(add_list)==list: if len(add_list)==1 and type(add_list[0])=='int': return add_list for item in add_list: try: if item%2==0: add_list.remove(item) add_list.insert(0,item) excep…
python每次处理一个字符的三种方法 a_string = "abccdea" print 'the first' for c in a_string: print ord(c)+1 print "the second" result = [ord(c)+1 for c in a_string] print result print "the thrid" def do_something(c): return ord(c)+1 result…
这几天有django和python做了一个多用户博客系统(可选择模板) 没完成,先分享下 断断续续2周时间吧,用django做了一个多用户博客系统,现在还没有做完,做分享下,以后等完善了再慢慢说 做的时候房展了博客园的部分功能,百度空间和新浪博客等,实现主要功能有 用户注册.登录,博客的发表.修改,文章分类的管理. 在文章发表里面用的是百度的ueditor,目前仅仅是用它来编辑,没有图片的上传等其他高级功能 在文章分类里面,要在数据库里面有一条记录 id为1,名称为未分类 用来做为所有用户的未分…
今天看到一个关于foo的一个面试题,赶脚特别有意思 function foo(){// 第16行 getName = function(){console.log(1)} return this } foo.getName = function(){ console.log(2) } foo.prototype.getName = function(){ console.log(3) } var getName = function(){ console.log(4) } function ge…
40多行python代码开发一个区块链?可信吗?我们将通过Python 2动手开发实现一个迷你区块链来帮你真正理解区块链技术的核心原理.python开发区块链的源代码保存在Github. 尽管有人认为区块链目前还是不成熟的解决方案,但它无疑是计算机发展史上的一个奇迹.但是,到底区块链是什么呢? 区块链 区块链是一个公开的数字账本,它按时间顺序记录比特币或其他加密货币发生的交易. 更一般的讲,区块链是一个公共数据库,新的数据将存储在一个被称为"块"的容器中,然后块会被添加到一个不可篡改的…
python 如何编写一个自己的包 先写function 内容 package/wadepypk$ ls __init__.py f1.py f2.py f1.py def show(): print("in pkg f.show()") f2.py def show(): print("in pkg f.show()") init.py __all__ = ['f1','f2'] 上层目录建立一个setup.py from distutils.core impor…
===================================== 看到 佩奇的广告片刷红,为了迎接猪年,咱们也来用Python  画板实现一个效果吧 from turtle import* def nose(x,y):#鼻子 penup()#提起笔 goto(x,y)#定位 pendown()#落笔,开始画 setheading(-30)#将乌龟的方向设置为to_angle/为数字(0-东.90-北.180-西.270-南) begin_fill()#准备开始填充图形 a=0.4 fo…
我最近用Python写了一个算法,不需要写任何规则就能自动识别一个网页的内容,目前测试了300多个新闻网站的新闻页,都能准确识别…
用Python写了一个postgresql函数,感觉很爽 CREATE LANGUAGE plpythonu; postgresql函数 CREATE OR REPLACE FUNCTION myfun1(text)   RETURNS text AS $BODY$ s = args[0] h = 0; n = len(s); for i, c in enumerate(s):         h = h + ord(c)*31**(n-1-i); bits = 4*8; return (h +…
把写代码过程中经常用到的一些代码段做个记录,如下代码段是关于python定义的一个简单的shell函数的代码. pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = pipe.communicate() return pipe.returncode, stdout, stderr…