del|append()|insert()|pop()|remove()|sort()|sorted|reverse()|len()|range()|min()|max()|sum()|[:]|区分两种列表复制|
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()|[:]|区分两种列表复制|的更多相关文章
- select into from和insert into select from两种表复制语句区别
select into from和insert into select from两种表复制语句都是将源表source_table的记录插入到目标表target_table,但两句又有区别. 第一句(s ...
- 问题:oracle select into;结果:oracle SELECT INTO 和 INSERT INTO SELECT 两种表复制语句详解
oracle SELECT INTO 和 INSERT INTO SELECT 两种表复制语句详解 (2011-07-08 08:59:47) 转载▼ 标签: it 分类: oracle 我们经常会遇 ...
- 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 ...
- PostgreSQL SELECT INTO和INSERT INTO SELECT 两种表复制语句
SELECT INTO和INSERT INTO SELECT两种表复制语句都可以用来复制表与表之间的数据,但是它们之间也有区别. 建表语句: bas_custom_rel表 CREATE TABLE ...
- sort sorted() reverse() reversed() 的区别1
sort()是可变对象(字典.列表)的方法,无参数,无返回值,sort()会改变可变对象,因此无需返回值.sort()方法是可变对象独有的方法或者属性,而作为不可变对象如元组.字符串是不具有这些方法的 ...
- sort sorted() reverse() reversed() 的区别
sort()是可变对象(字典.列表)的方法,无参数,无返回值,sort()会改变可变对象,因此无需返回值.sort()方法是可变对象独有的方法或者属性,而作为不可变对象如元组.字符串是不具有这些方法的 ...
- SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
Insert是T-sql中常用语句,Insert INTO table(field1,field2,...) values(value1,value2,...)这种形式的在应用程序开发中必不可少.但我 ...
- SELECT INTO 和 INSERT INTO SELECT 两种表复制语句.txt
Insert是T-sql中常用语句,Insert INTO table(field1,field2,...) values(value1,value2,...)这种形式的在应用程序开发中必不可少.但我 ...
- oracle SELECT INTO 和 INSERT INTO SELECT 两种表复制语句详解
我们经常会遇到需要表复制的情况,如将一个table1的数据的部分字段复制到table2中,或者将整个table1复制到table2中,这时候我们就要使用SELECT INTO 和 INSERT INT ...
随机推荐
- Hibernate--(二)增删改查
1.增删改查: public class Test { public static void main(String[] args) { SessionFactory sf = new Configu ...
- UVALive 4731 dp+贪心
这个题首先要利用题目的特性,先贪心,否则无法进行DP 因为求期望的话,越后面的乘的越大,所以为了得到最小值,应该把概率值降序排序,把大的数跟小的系数相乘 然后这种dp的特性就是转移的时候,由 i推到i ...
- 第二届中国“AI+”创新创业大赛完美收官,京东云赛道硕果累累
聚焦南京产业发展核心诉求,京东云携手南京政府构建的"平台+生态+赋能"的产业体系,搭建产业创新云平台,以人工智能产业创新链要素补齐为核心,围绕"研.产.供.销.服&quo ...
- 关于torch.nn.Conv2d的笔记
先看一下CLASS有哪些参数: torch.nn.Conv2d( in_channels, out_channels, kernel_size, stride=1, padding=0, dilati ...
- Sqlserver 增删改查----删
--我们就以院系,班级,学生来举例. create TABLE [dbo].YuanXi ( Id ,) NOT NULL,--学校id 自增量 YuanXiName varchar() null, ...
- jenkins+saltstack+pipeline 部署springcloud 多模块jar包
在jenkins上安装salt-master, pipeline{ agent{ node{ label 'master' cust ...
- php对象:__autoload()函数及单入口文件,__set(), __get(), get_class_methods(),get_class_vars()
__autoload():当类中找不到相关类的时候,会自动执行__autoload()函数,可以自动加载相关文件 __set() : 当对类的私有变量进行调用赋值时,自动调用该方法. __get() ...
- 直击JDD | 王振辉:技术是驱动物流革新的第一要素
"从物流基础设施的大规模智能迭代到产业供应链的数字化升级,物流行业从大而重变得'举重若轻',技术是驱动物流革新的第一要素."11月19日,京东物流集团CEO王振辉在2019京东全球 ...
- 简单的Vue计算属性
倒转字符串 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- python:创建文件夹:写入文本1:读取txt:读取Excel文件遍历文件夹:
https://blog.csdn.net/u011956147/article/details/80369731 创建文件夹: import osimport shutil def buildfil ...