python
云风Com
这个作者很懒,什么都没留下…
展开
-
python利用xwlt库写数据到excel
import xlwtworkbook = xlwt.Workbook(encoding='utf-8',style_compression=0)worksheet = workbook.add_sheet("sheet1", cell_overwrite_ok=True) #允许覆盖之前的内容worksheet.write(0, 0, 'hello') #行 列 内容workbook.save('stu.xls') #保存原创 2020-09-19 23:47:39 · 289 阅读 · 0 评论 -
爬虫学习之urllib详解
进入主程序入口if __name__ == "__main__": print('hello')urllibget请求import urllib.request#get方式response = urllib.request.urlopen("http://www.baidu.com")print(response)运行结果<http.client.HTTPResponse object at 0x000002A5EE9B8208>这是因为urlop.原创 2020-09-18 10:57:47 · 309 阅读 · 0 评论 -
python之lambda表达式,filter过滤器,map
lambda表达式g = lambda x, y: x * yprint(g(2, 3))其中x, y是参数, 这是一个匿名函数,用g来接收运行结果6filter过滤器print(filter(None , [1,2,True, False,0,5]))print(list(filter(None , [1,2,True, False,0,5])))运行结果<filter object at 0x000002ED570EE748>[1, 2, True, 5].原创 2020-09-16 18:32:31 · 1521 阅读 · 0 评论 -
python之函数,闭包
参数------ 收集参数 *参数名def stu(*info): print(info[0]) print(info[1]) print(len(info)) print(type(info))stu('shanxi', '200008966', 19)打印结果shanxi2000089663<class 'tuple'>返回值def stu(): return 0, 'shanxi', 50print(stu.原创 2020-09-16 17:53:55 · 96 阅读 · 0 评论 -
python之字符串、列表、元组
三目运算x = a if a > 3 else b断言assert当assert后面的语句为假时,抛出AssertionError异常rangerange(start,end,步长)listappend,向列表末尾追加元素(每次只能追加一个)extend,可以将一个列表扩展到另一个列表后面insert(位置,元素) 插入元素访问元素直接像数组一样下标访问删除元素remove (元素) 不需要知道位置,知道名字即可dellist.pop()从列表中弹出,中.原创 2020-09-15 18:48:57 · 97 阅读 · 0 评论