随笔分类 -  python

摘要:import httplib,urllib import re import random def Login(userid,password): params=urllib.urlencode({'id':userid,'pw':password}); headers={'Referer':'http://bbs.nju.edu.cn/cache_bb... 阅读全文
posted @ 2016-11-28 21:18 柳下_MBX 阅读(251) 评论(0) 推荐(0)
摘要:arlenmbx@arlenmbx-ThinkPad-X130e:~$ su root 密码: root@arlenmbx-ThinkPad-X130e:/home/arlenmbx# python Python 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on linux2 Type "help", "copyr... 阅读全文
posted @ 2016-11-24 12:20 柳下_MBX 阅读(396) 评论(0) 推荐(0)
摘要:1 import easygui as g 2 import sys 3 4 while 1: 5 g.msgbox("我一定要学会编程!","加油!") 6 #choices = ['愿意', '不愿意', '有钱的时候愿意'] 7 #g.choicebox('你愿意购买资源打包支持小甲鱼吗?', choices = choice... 阅读全文
posted @ 2016-11-10 23:32 柳下_MBX 阅读(568) 评论(0) 推荐(0)
摘要:1 >>> ls1=["nihia"] 2 >>> ls1 3 ['nihia'] 4 >>> ls1.pop() 5 'nihia' 6 >>> ls1.append("sssss") 7 >>> ls1 8 ['sssss'] 9 >>> assert len(ls1)>0 10 >>> ls1.pop() 11 'sssss' 12 >>> 阅读全文
posted @ 2016-11-10 01:46 柳下_MBX 阅读(578) 评论(0) 推荐(0)
摘要:1 >>> import pickle 2 >>> m_list=['1',2,'asa'] 3 >>> m_list 4 ['1', 2, 'asa'] 5 >>> m_file=open('my_file.pkl','wb') 6 >>> pickle.dump(m_list,m_file) 7 >>> pickle.close() 8 9 Traceback (most... 阅读全文
posted @ 2016-11-10 00:53 柳下_MBX 阅读(297) 评论(0) 推荐(0)
摘要:1 >>> help(open) 2 Help on built-in function open in module __builtin__: 3 4 open(...) 5 open(name[, mode[, buffering]]) -> file object 6 7 Open a file using the file() type, ... 阅读全文
posted @ 2016-11-09 23:32 柳下_MBX 阅读(413) 评论(0) 推荐(0)
摘要:set是一个工厂函数(filter也是工厂函数),是一个可变的集合 frozenset 不可变的集合,与set共性,他也在内部自动去重, 阅读全文
posted @ 2016-11-09 21:49 柳下_MBX 阅读(189) 评论(0) 推荐(0)
摘要:clear(),清空 注意单纯的赋值就相当于c语言中引用,只事额外起了一个别名,所以他们指向相同的地址, 所以令c={},只是另外开辟了一个新的空间让c为空,并没有改变之前的空间,所以{}与clear()看的功能一样,其实实现的原理不是一样的 上述说的时浅拷贝的问题 pop()删除指定的 popit 阅读全文
posted @ 2016-11-09 21:32 柳下_MBX 阅读(190) 评论(0) 推荐(0)
摘要:>>> dir1=dir(((1,100),(2,200))) >>> dir1 ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', 阅读全文
posted @ 2016-11-09 21:20 柳下_MBX 阅读(544) 评论(0) 推荐(0)
摘要:lambda 优点: 1:可以简单使用一个脚本来替代我们的函数 2:不用考虑命名的问题 3:简化代码的可读性,不用跳转到def了,省去这样的步骤 内置函数:bif filter:过滤器 map:映射 递归 python限制的递归深度大概几百层,但是可以手动设置 》》》import sys >>> s 阅读全文
posted @ 2016-11-09 15:52 柳下_MBX 阅读(155) 评论(0) 推荐(0)
摘要:函数的返回值可以是一个列表或一个元组,如果没有return,那么仍然会返回一个NONE,类型那个为typenone, 对于全局ii变量,我们在函数中只能进行引用,而不能进行修改 局部在堆栈中分配, 当我们你试图在函数中修改全局变量的时候,python会发生屏蔽,会在函数中发生屏蔽机制,额外创建一个临 阅读全文
posted @ 2016-11-09 01:39 柳下_MBX 阅读(2053) 评论(0) 推荐(0)
摘要:Python 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on linux2Type "copyright", "credits" or "license()" for more information.>>> def f 阅读全文
posted @ 2016-11-09 01:14 柳下_MBX 阅读(558) 评论(0) 推荐(0)
摘要:Python 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on linux2 Type "copyright", "credits" or "license()" for more information. >>> help(list) Help on class list in module __builtin__... 阅读全文
posted @ 2016-11-09 00:44 柳下_MBX 阅读(309) 评论(0) 推荐(0)
摘要:Python 2.7.12rc1 (v2.7.12rc1:13912cd1e7e8, Jun 12 2016, 05:57:31) [MSC v.1500 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> str1="i love fish" >>> str1... 阅读全文
posted @ 2016-11-09 00:09 柳下_MBX 阅读(963) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2016-11-08 23:20 柳下_MBX 阅读(100) 评论(0) 推荐(0)
摘要:tuple就是元组的类型,他和列表相近,但是也有很大的区别,如上,tuple不能修改元素,如果修改就会报错,如上 判断一个列表可以看中括号,但是看元组的依据主要是逗号 eg:如果我们只是需要一个元素,如果不加上逗号,那么会被默认为一个整数类型,如果在后面加上一个逗号,就会被认为是tuple 但是对于 阅读全文
posted @ 2016-09-29 00:31 柳下_MBX 阅读(1315) 评论(0) 推荐(0)
摘要:python自带的sort函数其实有3个参数,都有默认的值,第一个是func,代表解决的算法,python的sort是由归并排序解决的,第二格式key和func想对应。第三个是reverse就是反转,默认的值为false,如果希望、 sort从大到小排序,就将reverse赋值为True, list 阅读全文
posted @ 2016-09-28 23:40 柳下_MBX 阅读(470) 评论(0) 推荐(0)
摘要:列表切片 [:]取出中间的某一段元素切片,如果不加上,默认就是边界 阅读全文
posted @ 2016-09-28 22:56 柳下_MBX 阅读(311) 评论(0) 推荐(0)
摘要:python安装 选择 2.7及以上版本 初级教程 python2.7 tutorialpython入门指南主要学习python的基本语法, 常用的结构(元祖,列表, 字典) dive into python通过实例学习python基本库的使用Dive into python python libr 阅读全文
posted @ 2016-06-14 10:58 柳下_MBX 阅读(281) 评论(0) 推荐(0)