阿尔贝蒂娜博物馆(Albertina)是奥地利首都维也纳的一座博物馆,位于该市的内城区(第一区)。它拥有世界上最大最重要的版画室,有大约65,000幅图画和大约100万幅 old master print, 以及较现代的的图形作品,照片和建筑图纸。该博物馆除了收藏图像以外,最近用长期贷款收购了两批印象派和20世纪初艺术的重要藏品,其中一些将会永久展出。博物馆内还设有临时展览。
Python列表中extend和append有什么区别
python列表操作之extend和append的区别:
list.append(obj)
在列表末尾添加新的对象
list.extend(seq)
在列表末尾一次性追加另一个序列中的多个值(用新列表扩展原来的列表)
li = ['a', 'b', 'c']
li.extend(['d', 'e', 'f'])
print li
print len(li)
print li[-1]
li = ['a', 'b', 'c']
li.append(['d', 'e', 'f'])
print li
print len(li)
print li[-1]
运行结果如下:
['a', 'b', 'c', 'd', 'e', 'f']
6
f
['a', 'b', 'c', ['d', 'e', 'f']]
4
['d', 'e', 'f']
python列表操作之extend和append的区别:
list.append(obj)
在列表末尾添加新的对象
list.extend(seq)
在列表末尾一次性追加另一个序列中的多个值(用新列表扩展原来的列表)
li = ['a', 'b', 'c']
li.extend(['d', 'e', 'f'])
print li
print len(li)
print li[-1]
li = ['a', 'b', 'c']
li.append(['d', 'e', 'f'])
print li
print len(li)
print li[-1]
运行结果如下:
['a', 'b', 'c', 'd', 'e', 'f']
6
f
['a', 'b', 'c', ['d', 'e', 'f']]
4
['d', 'e', 'f']
Python列表怎么更新值
序列是Python中最基本的数据结构。序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推。
Python有6个序列的内置类型,但最常见的是列表和元组。
序列都可以进行的操作包括索引,切片,加,乘,检查成员。
此外,Python已经内置确定序列的长度以及确定和最小的元素的方法。
列表是最常用的Python数据类型,它可以作为一个方括号内的逗号分隔值出现。
列表的数据项不需要具有相同的类型
创建一个列表,只要把逗号分隔的不同的数据项使用方括号括起来即可。如下所示:
list1 = ['physics', 'chemistry', 1997, 2000]
list2 = [1, 2, 3, 4, 5 ]
list3 = ["a", "b", "c", "d"]
与字符串的索引一样,列表索引从0开始。列表可以进行截取、组合等。
那如何在python中更新列表呢?
aList = [123, 'abc', 4.56, ['inner', 'list'], (7-9j)]
print aList[2]
aList[2] = 'float replacer'
print aList
aList.append("hi, i'm new here")
print aList
运行结果如下:
4.56
[123, 'abc', 'float replacer', ['inner', 'list'], (7-9j)]
[123, 'abc', 'float replacer', ['inner', 'list'], (7-9j), "hi, i'm new here"]
序列是Python中最基本的数据结构。序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推。
Python有6个序列的内置类型,但最常见的是列表和元组。
序列都可以进行的操作包括索引,切片,加,乘,检查成员。
此外,Python已经内置确定序列的长度以及确定和最小的元素的方法。
列表是最常用的Python数据类型,它可以作为一个方括号内的逗号分隔值出现。
列表的数据项不需要具有相同的类型
创建一个列表,只要把逗号分隔的不同的数据项使用方括号括起来即可。如下所示:
list1 = ['physics', 'chemistry', 1997, 2000]
list2 = [1, 2, 3, 4, 5 ]
list3 = ["a", "b", "c", "d"]
与字符串的索引一样,列表索引从0开始。列表可以进行截取、组合等。
那如何在python中更新列表呢?
aList = [123, 'abc', 4.56, ['inner', 'list'], (7-9j)]
print aList[2]
aList[2] = 'float replacer'
print aList
aList.append("hi, i'm new here")
print aList
运行结果如下:
4.56
[123, 'abc', 'float replacer', ['inner', 'list'], (7-9j)]
[123, 'abc', 'float replacer', ['inner', 'list'], (7-9j), "hi, i'm new here"]
✋热门推荐