码迷,mamicode.com
首页 >  
搜索关键字:python module    ( 144473个结果
笨方法学python(6)加分题--列表与字典的区别
这篇对应的是习题39 字典, 可爱的字典 #encoding:utf-8 #列表与字典的区别 #列表 thing = ['name',1,'age','AD','sex'] print thing[1] #print thing['name'] #会报错,列表只能通过整数去访问:TypeError: list indices must be integers, not str stuff...
分类:编程语言   时间:2014-05-07 06:00:20    阅读次数:365
python中的字符串处理
1.字符串转换 s.lower()   转为小写 s.upper()  转为大写 s.swapcase()   大写转为小写,小写转为大写 s.capitalize()  首字母大写 转换为int类型  string.atoi(s)   或者int(s) 转换为float类型  string.atof(s)  或者float(s) 转换为long类型   string.atol(s)...
分类:编程语言   时间:2014-05-07 04:09:36    阅读次数:433
python里的splitlines详解
t = '''www.jeapedu.com www.chinagame.me www.quanzhan.org ''' print t.splitlines()     Python的split方法函数可以分割字符串成列表,默认是以空格作为分隔符sep来分割字符串。 In [1]: s = "www jeapedu com" In [2]: p...
分类:编程语言   时间:2014-05-07 02:37:08    阅读次数:478
python数据结构与算法 36 树的基本概念
树 学习目标 理解什么是树及使用方法 学会使用树实现映射 用列表实现树 用类和引用实现树 用递归实现树 用堆实现优先队列 树的例子 前面我们学习过栈和队列这类线性数据结构,并且体验过递归,现在我们学习另一种通用数据结构,叫做树。树在计算机科学中应用广泛,象操作系统、图形学、数据库系统、网络等都要用到树。树和他们在自然界中的表哥——植物树——非常相似,树也有根,有分枝,有叶子...
分类:编程语言   时间:2014-05-06 23:24:22    阅读次数:447
codechef Correctness of Knight Move题解
Chef develops his own computer program for playing chess. He is at the very beginning. At first he needs to write the module that will receive moves written by the players and analyze it. The module w...
分类:其他好文   时间:2014-05-06 23:11:26    阅读次数:497
python修改文件名
最近下了《中国式英语口语纠错》里面的文件都是“tingvoa.com_cnusa043.mp3”,MP3播放器不识别, 因此用python脚本写了一个rename的脚本 # -*- coding: utf-8 -*- import os def filerename(path):     for file in os.listdir(path):         #pr...
分类:编程语言   时间:2014-05-06 22:48:40    阅读次数:423
[简明python教程]学习笔记2014-05-05
今天学习了python的输入输出、异常处理和python标准库1.文件通过创建一个file类的对象去处理文件,方法有read、readline、write、close等[root@reed0505]#catusing_file.py #!/usr/bin/python #filename:using_file.py poem=‘‘‘Programingisfun whentheworkisdone usePython!..
分类:编程语言   时间:2014-05-06 17:05:03    阅读次数:448
python学习笔记
将文件的每行读取到字典中文件每行内容格式为:cui:123456789f=open(‘user.txt‘) d=f.readlines() f.close() mydict={} foriind: user=i.split(‘:‘)[0] info=i.split(‘:‘)[1].rstrip() mydict[user]=info
分类:编程语言   时间:2014-05-06 16:40:26    阅读次数:362
No module named yum错误的解决办法
今天用yum安装软件的时候出现如下错误:TherewasaproblemimportingoneofthePythonmodulesrequiredtorunyum.Theerrorleadingtothisproblemwas:NomodulenamedyumPleaseinstallapackagewhichprovidesthismodule,orverifythatthemoduleisinstalledcorrectly.It’spossiblethattheabo..
分类:其他好文   时间:2014-05-06 16:09:23    阅读次数:297
Optipng,jpegoptim应用,用python实现图片压缩,让你的网站变得更快
compressp_w_picpathsaccordingtogooglesuggestion.1.环境:ubuntu12.04、python2.7.32.工具:optipng、jpegoptim。3.安装工具:a.sudoapt-getinstalloptipngb.sudoapt-getinstalljpegoptim4.a.使用方法:optipng/filepath/filename.png.一个例子:optipng/home/pwprice/work/p..
分类:编程语言   时间:2014-05-06 15:47:33    阅读次数:430
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!