fruit = ['apple','banana','peach']
print fruit[0],fruit[-1] fruit_1 =[]
fruit_1.append('orange')
print fruit_1 fruit.insert(1,'orange')
del fruit[2]
print fruit '''
apple peach
['orange']
['apple', 'orange', 'peach']
''' pop_1 = fruit.pop(1)
print pop_1,"\n",fruit '''
orange
['apple', 'peach']
''' apple = 'apple'
fruit.remove(apple)
print fruit,"\n",fruit_1 '''
['peach']
['orange']
''' fruit_2 = ['a','b','c','d','e','f']
fruit = fruit_1 + fruit_2
print fruit '''
['orange', 'a', 'b', 'c', 'd', 'e', 'f']
'''
new_fruit = sorted(fruit,reverse=True)
print fruit,"\n",new_fruit
new_fruit.sort(reverse=True)
print new_fruit
new_fruit.reverse()
print new_fruit '''
['orange', 'a', 'b', 'c', 'd', 'e', 'f']
['orange', 'f', 'e', 'd', 'c', 'b', 'a']
['orange', 'f', 'e', 'd', 'c', 'b', 'a']
['a', 'b', 'c', 'd', 'e', 'f', 'orange'] ''' length = len(new_fruit)
print length # #empty = []
#iprint empty[-1] '''
Traceback (most recent call last):
File "t.py", line 61, in <module>
print empty[-1]
IndexError: list index out of range
''' for i in new_fruit:
print i
print i '''
a
b
c
d
e
f
orange
orange
''' new_list = list(range(1,15,3))
print new_list #[1, 4, 7, 10, 13] max_in_list = max(new_list)
min_in_list = min(new_list)
sum_in_list = sum(new_list)
print max_in_list,"\n",min_in_list,"\n",sum_in_list '''
13
1
35
'''
double=[i**2 for i in range(1,20)]
new_double = double[:]
print new_double
print double[4:] #[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361]
#[25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361] for single in double[5:-1]:
print single '''
36
49
64
81
100
121
144
169
196
225
256
289
324
'''
new_double_2 = double
double.pop(0)
print double
print new_double_2
print new_double '''
[4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361]
[4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361]
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361]
''' new_double[1] =2500000000000
print new_double #[1, 2500000000000, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361] scale = [1,8]
for number in scale:
print number scale = (1,8)
for number in scale:
print number '''
1
8
1
8
'''

问题:列表可以用[ ]or( )???

 scale = [1,8]
for number in scale:
print number scale = (1,8)
for number in scale:
print number '''
1
8
1
8
'''

del|append()|insert()|pop()|remove()|sort()|sorted|reverse()|len()|range()|min()|max()|sum()|[:]|区分两种列表复制|的更多相关文章

  1. select into from和insert into select from两种表复制语句区别

    select into from和insert into select from两种表复制语句都是将源表source_table的记录插入到目标表target_table,但两句又有区别. 第一句(s ...

  2. 问题:oracle select into;结果:oracle SELECT INTO 和 INSERT INTO SELECT 两种表复制语句详解

    oracle SELECT INTO 和 INSERT INTO SELECT 两种表复制语句详解 (2011-07-08 08:59:47) 转载▼ 标签: it 分类: oracle 我们经常会遇 ...

  3. oracle数据库【表复制】insert into select from跟create table as select * from 两种表复制语句区别

    create table  as select * from和insert into select from两种表复制语句区别 create table targer_table as select ...

  4. PostgreSQL SELECT INTO和INSERT INTO SELECT 两种表复制语句

    SELECT INTO和INSERT INTO SELECT两种表复制语句都可以用来复制表与表之间的数据,但是它们之间也有区别. 建表语句: bas_custom_rel表 CREATE TABLE ...

  5. sort sorted() reverse() reversed() 的区别1

    sort()是可变对象(字典.列表)的方法,无参数,无返回值,sort()会改变可变对象,因此无需返回值.sort()方法是可变对象独有的方法或者属性,而作为不可变对象如元组.字符串是不具有这些方法的 ...

  6. sort sorted() reverse() reversed() 的区别

    sort()是可变对象(字典.列表)的方法,无参数,无返回值,sort()会改变可变对象,因此无需返回值.sort()方法是可变对象独有的方法或者属性,而作为不可变对象如元组.字符串是不具有这些方法的 ...

  7. SELECT INTO 和 INSERT INTO SELECT 两种表复制语句

    Insert是T-sql中常用语句,Insert INTO table(field1,field2,...) values(value1,value2,...)这种形式的在应用程序开发中必不可少.但我 ...

  8. SELECT INTO 和 INSERT INTO SELECT 两种表复制语句.txt

    Insert是T-sql中常用语句,Insert INTO table(field1,field2,...) values(value1,value2,...)这种形式的在应用程序开发中必不可少.但我 ...

  9. oracle SELECT INTO 和 INSERT INTO SELECT 两种表复制语句详解

    我们经常会遇到需要表复制的情况,如将一个table1的数据的部分字段复制到table2中,或者将整个table1复制到table2中,这时候我们就要使用SELECT INTO 和 INSERT INT ...

随机推荐

  1. 二十三、CI框架之post

    一.在控制器里面代码如下: 二.在View里面写好按钮和需要post的代码 三.效果如下,点击按钮之前: 点击按钮之后, 不忘初心,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额 ...

  2. 用豆瓣加速安装pandas、numpy、matplotlib(画图)

    安装pandas.numpy会同时被安装 #pthony2.x,用豆瓣加速安装pandas pip install -i https://pypi.doubanio.com/simple/ panda ...

  3. 桥接 brctl

    把eth0和wlan0桥接在一起 作用:测试wlan0网卡的并发性能   两个网卡桥接后把linux主机模拟成一个“无线路由交换机” Vi   br0.sh #!/bin/bash ifconfig ...

  4. Q7:Reverse Integer

    7. Reverse Integer 官方的链接:7. Reverse Integer Description : Given a 32-bit signed integer, reverse dig ...

  5. HttpClient系列~StringContent与FormUrlEncodedContent

    知识点 本文是一个很另类的文章,在项目中用的比较少,但如果项目中真的出现了这种情况,我们也需要知道如何去解决,对于知识点StringContent和FormUrlEncodedContent我们应该了 ...

  6. 谷歌 notification 测试 页面

    <button onclick="notifyMe('master wei','http://cdn.sstatic.net/stackexchange/img/logos/so/so ...

  7. java.io.tmpdir在哪里?

    查找所在目录的方式如下: System.out.println(System.getProperty(“java.io.tmpdir”)); System.getProperty(),还可以获取更多其 ...

  8. KL散度与JS散度

    1.KL散度 KL散度( Kullback–Leibler divergence)是描述两个概率分布P和Q差异的一种测度.对于两个概率分布P.Q,二者越相似,KL散度越小. KL散度的性质:P表示真实 ...

  9. jenkins job 杀进程不成功解决办法

    jenkins_job #!/bin/bash set -ex #打印执行过程 BUILD_ID=DONTKILLME #防止自杀 ssh dataexa@192.168.1.65 > /dev ...

  10. pcl 1.8 + VS 2010 在win7 x64下的配置

    https://blog.csdn.net/zhangping560/article/details/53978011 版权声明:(转载请注明作者和出处:http://blog.csdn.net/zh ...