这篇对应的是习题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
方法一(最简单安装):
安装 Net-SNMP
CentOS及其它RedHat系列产品提供了net-snmp的二进制包。我们可以直接从源里安装。
shell> yum install net-snmp net-snmp-devel net-snmp-utils
说明:net-snmp-devel是为了使用net-snmp-config, net-snmp-utils是为了使...
分类:
其他好文 时间:
2014-05-07 02:48:36
阅读次数:
428
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
最近下了《中国式英语口语纠错》里面的文件都是“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
实验需求:在服务器本机搭建mysql图形管理工具1.简单部署LAMP平台#yum-yinstallhttpdmysqlmysql-serverphpphp-mysqlphp-pdo#rpm-ivhphp-mbstring-5.3.3-26.el6.x86_64.rpm//此包安装光盘没有,需自己下载2.修改httpd配置文件,启动服务#vim/etc/httpd/conf/httpd.conf……Serve..
分类:
Web程序 时间:
2014-05-06 18:30:37
阅读次数:
469
今天学习了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
将文件的每行读取到字典中文件每行内容格式为: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
今天用yum安装软件的时候出现如下错误:TherewasaproblemimportingoneofthePythonmodulesrequiredtorunyum.Theerrorleadingtothisproblemwas:NomodulenamedyumPleaseinstallapackagewhichprovidesthismodule,orverifythatthemoduleisinstalledcorrectly.It’spossiblethattheabo..
分类:
其他好文 时间:
2014-05-06 16:09:23
阅读次数:
297
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
一1、配置YUM源(自己手写,要精确到GPGK。。。。)Name=写名字中间最好有个空格不会手写yum源,查看MAN帮助:manyum.conf若YUM起不来,可去掉gpg~~或添加gpg~~~二1、调整逻辑卷减小逻辑卷:逻辑卷始终大于文件系统大小三1、创建用户账户:chage–d0natasha指定用户下次登录修?.
分类:
其他好文 时间:
2014-05-06 15:44:56
阅读次数:
528