搜索到与相关的文章
Python

python实现图片压缩代码实例

前言项目中大量用到图片加载,由于图片太大,加载速度很慢,因此需要对文件进行统一压缩一:导入包fromPILimportImageimportos二:获取图片文件的大小defget_size(file):#获取文件大小:KBsize=os.path.getsize(file)returnsize/1024三:拼接输出文件地址defget_outfile(infile,outfile):ifoutfile:returnoutfiledir,suffix=os.

系统 2019-09-27 17:46:02 2156

Python

Python判断字符串与大小写转换

判断字符串s.isalnum()#所有字符都是数字或者字母s.isalpha()#所有字符都是字母s.isdigit()#所有字符都是数字s.islower()#所有字符都是小写s.isupper()#所有字符都是大写s.istitle()#所有单词都是首字母大写,像标题s.isspace()#所有字符都是空白字符、\t、\n大小写转换s.upper()#把所有字符中的小写字母转换成大写字母s.lower()#把所有字符中的大写字母转换成小写字母s.cap

系统 2019-09-27 17:45:51 2156

Python

CentOS配置python操作

centos7.3安装python查看当前python情况[root@localhost/]#cd/[root@localhostbin]#cd/usr/bin[root@localhostbin]#lspython*pythonpython2python2.7[root@localhostbin]#ls-alpython*修改软连接[root@localhostbin]#mvpythonpython.bak开始做下载准备[root@localhostbi

系统 2019-09-27 17:45:46 2156

Python

Python里隐藏的“禅”

在python的lib目录里有一个:this.py,它其实是隐藏着一首诗,源码如下:复制代码代码如下:s="""GurMrabsClguba,olGvzCrgrefOrnhgvshyvforggregunahtyl.Rkcyvpvgvforggregunavzcyvpvg.Fvzcyrvforggregunapbzcyrk.Pbzcyrkvforggregunapbzcyvpngrq.Syngvforggregunaarfgrq.Fcnefrvforggr

系统 2019-09-27 17:38:46 2156

Python

在Python中调用ggplot的三种方法

本文提供了三种不同的方式在Python(IPythonNotebook)中调用ggplot。在大数据时代,数据可视化是一个非常热门的话题。各个BI的厂商无不在数据可视化领域里投入大量的精力。Tableau凭借其强大的数据可视化的功能成为硅谷炙手可热的上市公司。Tableau的数据可视化的产品,其理论基础其实是《TheGrammarofGraphic》,该书提出了对信息可视化的图表的语法抽象体系,数据的探索和分析可以由图像的语法来驱动,而非有固定的图表类型来

系统 2019-09-27 17:38:39 2156

Python

python目录与文件名操作例子

1、操作目录与文件名#!/usr/bin/envpython#-*-coding:utf-8-*-importos,reimportshutilimporttime用listdir搜索defsearch_OFD_old(my_pattern,diretory):try:names=os.listdir(diretory)exceptos.error:print"error"returnfornameinnames:fullname=os.path.norm

系统 2019-09-27 17:38:36 2156

Python

Linux安装Python虚拟环境virtualenv的方法

1、安装virtulenv、virtulenvwrapper包pipinstallvirtualenvvirtualenvwrapper2、virtualenvwrapper是virtualenv的扩展工具,可以方便的创建、删除、复制、切换不同的虚拟环境。3、设置环境变量,把下面两行添加到~/.bash_profile里exportWORKON_HOME=/software/venvsource/usr/local/bin/virtualenvwrappe

系统 2019-09-27 17:38:34 2156

Python

浅谈python中的getattr函数 hasattr函数

hasattr(object,name)作用:判断对象object是否包含名为name的特性(hasattr是通过调用getattr(ojbect,name)是否抛出异常来实现的)。示例:>>>hasattr(list,'append')True>>>hasattr(list,'add')Falsegetattr(object,name,default):作用:返回object的名称为name的属性的属性值,如果属性name存在,则直接返回其属性值;如果属

系统 2019-09-27 17:38:20 2156

Python

python连接mysql实例分享

示例一#coding=UTF-8importsysimportMySQLdbimporttimereload(sys)sys.setdefaultencoding('utf-8')defconnectDemo():returnMySQLdb.Connection("127.0.0.1","root","root","demo",3306,charset="utf8")if__name__=='__main__':begin=time.time()conn=

系统 2019-09-27 17:37:59 2156

编程技术

第一个居于as 的hello world程序

package{importflash.display.Sprite;importflash.text.*;publicclassASProjectextendsSprite{publicfunctionASProject(){varmytext:TextField=newTextField();mytext.text="helloworld";addChild(mytext);}}}第一个居于as的helloworld程序

系统 2019-08-29 23:52:30 2156