这篇对应的是习题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
题目链接:http://poj.org/problem?id=3041
Asteroids
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 14022
Accepted: 7629
Description
Bessie wants to...
分类:
其他好文 时间:
2014-05-07 05:59:05
阅读次数:
366
本文只讲述typeid这个操作符,呃 ,它确实是一个操作符,类似于 sizeof 操作符。
在将该操作符之前,不得不提的是
RTTI(Run-Time Type Identification,运行时类型识别),其实就是说在运行期得到对
象的实际的类型。这立刻使我们想到了
“可以通过基类的指针和引用可以指向实际的派生类型”。啊哦,答对了,这就是typeid
这个强大操作符所做的事...
分类:
编程语言 时间:
2014-05-07 05:58:26
阅读次数:
350
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
每条边有两种连法,在圆的外侧或圆的内侧. 对于有可能相交的两条边,不能在同一侧. 建图判断2sat
Ikki's Story IV - Panda's Trick
Time Limit: 1000MS
Memory Limit: 131072K
Total Submissions: 7692
Accepted: 284...
分类:
其他好文 时间:
2014-05-06 23:32:06
阅读次数:
431
最近下了《中国式英语口语纠错》里面的文件都是“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
Count the string
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4212 Accepted Submission(s): 1962
Problem Description
It is wel...
分类:
其他好文 时间:
2014-05-06 15:27:24
阅读次数:
306