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. 18 12 28 css 浮动 定位

    浮动 浮动特性 1.浮动元素有左浮动(float:left)和右浮动(float:right)两种 2.浮动的元素会向左或向右浮动,碰到父元素边界.其他元素才停下来 3.相邻浮动的块元素可以并在一行, ...

  2. vsCode--设置显示文件和搜索过滤

    文件位置:文件(File)-首选项(Preference)-设置(setting) 打开setting.json文件输入一下内容即可 { "search.exclude": { & ...

  3. shell 疑难

    #!/bin/bashBIN=`which $0`BIN=`dirname ${BIN}`BIN=`cd "$BIN"; pwd`  #列出脚本所在目录全局路径

  4. 抓DHCP客户端ip脚本

    cat testnew.sh #!/bin/bash catch_ip (){Ip=`sudo nmap -sP 192.168.1.0/24 |grep -i -B2 $mac|grep Nmap ...

  5. 分布式CAP定理(转)

    在弄清楚这个问题之前,我们先了解一下什么是分布式的CAP定理. 根据百度百科的定义,CAP定理又称CAP原则,指的是在一个分布式系统中,Consistency(一致性). Availability(可 ...

  6. Shell脚本exit用法与区别

    在Shell脚本中,往往会遇到一些判断类型为某个值不符合预期值的时候就退出主脚本/当前脚本/当前函数,那么Exit与return的用法与区别是什么呢? 下面先使用Exit举个简单例子,脚本内容如下 # ...

  7. HTML超链接实例介绍

    <html><head><title>第六节课</title><meta charset="UTF-8"></he ...

  8. 吴裕雄--天生自然 JAVASCRIPT开发学习:函数定义

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  9. No module named cv2 报错处理

    运行python脚本出现“No module named cv2 ”,这时我们安装下opencv-python依赖即可 python3 -m pip install opencv-python

  10. alert(1&&2)的输出问题

    此文章转载自http://blog.csdn.net/xiaotao_css/article/details/61940664 一.先来说说 ||(逻辑或),从字面上来说,只有前后都是false的时候 ...