这篇对应的是习题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
转载自:http://blog.csdn.net/showhilllee/article/details/8746114
貌似ASI里获取ip地址的链接不可以了。也曾试过whatismyip,在其网站上的截图获取的ip是正确的,单不知道为什么在我这里却是错误的。所以,在这里分享一下获得手机ip的方法。代码最初源自老外,通过系统提供的api获取的,这里我就直接贴代码了:
在创建的获得...
分类:
移动开发 时间:
2014-05-07 03:04:55
阅读次数:
595
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
我们退出Activity可以调用:finish(),system(0),但是这些都只是单单退出单个Activity
也有人会说,直接把进程杀死,这些做法都不是很可取,其实我们翻看api可以发现,Activity
都是放入stack中管理,我们只要把stack清空了,不就完全退出了嘛。要对Activity的stack
管理,就需要了解launchMode的四种状态,这里...
分类:
移动开发 时间:
2014-05-06 23:40:01
阅读次数:
409
lzugis——Arcgis Server for JavaScript API之POI...
分类:
编程语言 时间:
2014-05-06 23:22:57
阅读次数:
524
最近下了《中国式英语口语纠错》里面的文件都是“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
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