python两个dict相加
>>> a = {'1':'2'}
>>> b = {'3':'4'}
>>> a+b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
>>> a.update(b)
>>> a
{'1': '2', '3': '4'}
>>>
该方法把b的元素加入到a中去,键字重复时会覆盖a中的键值
相关文档:
客户给一堆图片要传到后台,图片太大了,上百张图用photoshop改太慢,就想到用python写个简单的批处理。功能简单就是把原图按比例缩小,代码更简单 20多行。
# -*- coding: cp936 -*-
import Image
import glob, os
#图片批处理
def timage():
for files in glob.glob('D:\\1\\*.JPG'):
filepath,filena ......
Pythonwin - Python IDE and GUI Framework for Windows.
Copyright 1994-2006 Mark Hammond
Python is Copyright (c) 2000-2008 ActiveState Software Inc.
Copyright (c) 2001-2008 Python Software Foundation.
All Rights Reserved.
Copyright (c) 2000 BeOpen.com.
All Rights Reserved.
Copyright (c) 1995-20 ......
在Python中有些特殊的地方是存在两种字符串,分别为str和unicode字符串,他们都继承自basestring。
如:s="hello world",s为str;us=u"hello world",us为unicode。
使用help(str)和help(unicode)可以查看各自说明,他们都有decode、encode方法,
decode用于将str字符串解码为unicode字符串,
encode用于将unicode字符 ......
学习了第八章后,紧锣密鼓的开始第九章的学习。
学习了“数据结构操作”,学习了“文件操作”。“数据结构操作”还比较有意思,看得懂。“文件操作”就开始头昏昏的,像脑子进了浆糊。
好不容易看到“操作程序”,才发现“操作程序”这一节的内容并不是我所 ......
3、Lists 数据类型
在python中,lists是序列容器,它可以容纳任何类型的对象。和strings不同,Lists支持原地修改(mutalbe in place),通过下标引用的方式,可以修改Lists的内容,如p是Lists对象, 则可以通过p[1] = '123'这种的方式改变p的内容。
Lists是序列容器,支持任何序列 ......