有很久没有更新我的博客了,在学习flask去了,别人都说flask不难,其实现在我也这么觉得,但是在刚接触的时候还是有点吃力的。在学习的过程中查阅了不少,也了解了许多,今天想做个总结。。。以免觉得学了那么久什么都没学到,还有防止以后忘记。一.关于装饰器,路由最开始接触的时候觉得好神奇,只会照着敲不知道怎么自己用起来@app.route(‘/')defhello:print(‘hello')注意:1.只有@这个东西是固定的,app是可以换的,这与蓝本中的定义
系统 2019-09-27 17:48:05 1711
5.16列表生成式l=[]foriinrange(100):l.append('egg%s'%i)print(l)l=['egg%s'%iforiinrange(100)]l=['egg%s'%iforiinrange(1000)ifi>10]print(l)5.17列表生成式与生成器表达式的应用names=['egon','alex_sb','wupeiqi','yuanhao','lxx']res=map(lambdax:x.upper(),name
系统 2019-09-27 17:48:05 1711
python调用短信猫控件实现发短信功能实例代码如下所示:#!/usr/bin/envpython#coding=gbkimportsysimportwin32com.clientocxname='ShouYan_SmsGate61.Smsgate'axocx=win32com.client.Dispatch(ocxname)axocx.CommPort=8#设置COM端口号axocx.SmsService='+8613800100500'#设置短信服务号
系统 2019-09-27 17:47:54 1711
闲来无事,想看看python,网上看了一下教程,好像入门问题不大,那就说干就干。先大概了解一下python的语法。传送门:https://www.runoob.com/python/python-tutorial.html最基础的语法啊,balabala一堆,反正先看下,了解一下。然后就是来搭建一下环境,网上看了一下,linux如何搭建python环境,一看吓一跳,linux本身自带python运行环境。这么刺激的嘛,赶紧打开我的linux,先瞅瞅:终端下
系统 2019-09-27 17:47:45 1711
原始数据原始数据大致是这样子的:每条数据中的四个数据分别是当前节点名称,节点描述(指代一些需要的节点属性),源节点(即最顶层节点),父节点(当前节点上一层节点)。datas=[["root","根节点","root",None],["node1","一级节点1","root","root"],["node2","一级节点2","root","root"],["node11","二级节点11","root","node1"],["node12","二级节点1
系统 2019-09-27 17:47:39 1711
类代码:#-*-coding:gbk-*-importosclassTABFILE:def__init__(self,filename,dest_file=None):self.filename=filenameifnotdest_file:self.dest_file=filenameelse:self.dest_file=dest_fileself.filehandle=Noneself.content=[]self.initflag=Falsesel
系统 2019-09-27 17:47:28 1711
#这是Python中的一个字典dic={'str':'thisisastring','list':[1,2,'a','b'],'sub_dic':{'sub_str':'thisissubstr','sub_list':[1,2,3]},'end':'end'}//这是javascript中的一个JSON对象json_obj={'str':'thisisastring','arr':[1,2,'a','b'],'sub_obj':{'sub_str':'t
系统 2019-09-27 17:47:24 1711
在python的官方文档中:getattr()的解释如下:getattr(object,name[,default])Returnthevalueofthenamedattributeofobject.namemustbeastring.Ifthestringisthenameofoneoftheobject'sattributes,theresultisthevalueofthatattribute.Forexample,getattr(x,'fooba
系统 2019-09-27 17:47:19 1711
本文以实例形式实现了python监控linux性能以及进程消耗性能的方法,具体实现代码如下:#-*-coding:utf-8-*-"""CreatedonTueJun1010:20:132014@author:lifeix"""fromcollectionsimportOrderedDictimporttimeimportosdefcpuinfo():lines=open('/proc/stat').readlines()forlineinlines:ln
系统 2019-09-27 17:47:12 1711
swapCase()方法返回所有可大小写,基于字符大小写交换字符串的一个副本。语法以下是swapCase()方法的语法:str.swapcase();参数NA返回值此方法返回其中所有基于大小写字符交换字符串的一个副本。例子下面的例子显示的swapCase()方法的使用。#!/usr/bin/pythonstr="thisisstringexample....wow!!!";printstr.swapcase();str="THISISSTRINGEXAMP
系统 2019-09-27 17:47:06 1711