这篇对应的是习题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
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
方法一(最简单安装):
安装 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
在一些对安全性要求较高的场景下,ssh的超时时间是管理员预先设置好的,在闲置一段时间后ssh连接会自动断开。这种情况下如果通过ssh执行脚本,而脚本运行时间又比较长的话,会导致ssh客户端和服务器长时间无交互而超时,命令执行失败。
使用bash子进程可以解决这种问题,思路是由子进程执行具体的逻辑代码,而由主进程来监控子进程的执行状态,同时向控制台输出字符来keep alive。
bash创建子...
分类:
其他好文 时间:
2014-05-06 23:30:56
阅读次数:
366
最近下了《中国式英语口语纠错》里面的文件都是“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的输入输出、异常处理和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
这不是一个难题,只是记录下来我的经验,如有不当或者错误之处,请各位不吝赐教。我原来在一家在线监控车辆位置的软件公司上班,产品初创之时,有许多系统上线,诸如,给客户使用的系统,给运营公司使用的系统,还有后台监控支撑系统,而且各种系统使用的域名不同,技术语言不..
分类:
Web程序 时间:
2014-05-06 16:29:41
阅读次数:
817
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