Python自学:第四章 复制列表(1)
# -*- coding: GBK -*- my_foods = ['pizza', 'falafel', 'carrot cake']
friend_foods = my_foods[:] print("My favorite foods are:")
print(my_foods) print("\nMy friend's favorite foods are:")
print(friend_foods)
输出为:
My favorite foods are:
['pizza', 'falafel', 'carrot cake'] My friend's favorite foods are:
['pizza', 'falafel', 'carrot cake']
Python自学:第四章 复制列表(1)的更多相关文章
- Python自学:第四章 切片
# -*- coding: GBK -*- players = ['charles', 'martina', 'michael', 'florence', 'eli'] print(players[0 ...
- Python自学:第三章 确定列表长度
>>> cars = ["bmw", "audi", "toyota", "subaru"] > ...
- Python自学:第三章 在列表末尾添加元素与在列表中插入元素
motorcycles = ['honda', 'yamaha' ,'suzuki'] motorcycles.insert(0, "ducati") print(motorcyc ...
- Python自学:第三章 修改列表元素
motorcycles = ['honda', 'yamaha', 'suzuki'] print(motorcycles) motorcycles[0] = 'ducati' print(motor ...
- Python自学:第三章 使用列表中的各个值
bicycles = ['trek','cannondale','redline','specialized'] message = "My first bicycle was a &quo ...
- Python自学:第三章 访问列表元素
#输出并首字母大写 bicycles = ['trek','cannondale','redline','specialized'] print(bicycles[0].title()) 输出为: T ...
- Python自学:第四章 遍历切片
# -*- coding: GBK -*- players = ['charles', 'martina', 'michael', 'florence', 'eli'] print("Her ...
- Python自学:第四章 在for循环结束后执行一些操作
# -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(ma ...
- Python自学:第四章 在for循环中执行更多操作(2)
# -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(ma ...
随机推荐
- 消费kafka的消息,并将其SparkStreaming结果保存到mysql
将数据保存到mysql,需要用到jdbc.为了提高保存速度,我写了一个连接池 1.保存到mysql的代码 package test05 import org.apache.log4j.{Level, ...
- 【转载】vue install报错run `npm audit fix` to fix them, or `npm audit` for details html
原链接https://www.jianshu.com/p/60591cfc6952 执行npm install 出现如下提醒 added 253 packages from 162 contribut ...
- sort -n
输入如下测试数据: 当按照第一列排列时是正确的: 但按照第二列排序时,喵喵喵???怎么跟说好的不一样啊!!!为什么gugu的50会排在最后? 其实是因为默认是按照第二列的第一个字符来比较的,若想 ...
- 【LeetCode】Heap
[215] Kth Largest Element in an Array [Medium] 给个无序数组,返回第K大的数字. 方法1. 直接使用优先队列 priority_queue class S ...
- java笔试题大全之IO流常见选择题
1.下面哪个流类属于面向字符的输入流()选择一项)A. BufferedWriterB. FileInputStreamC. ObjectInputStreamD. InputStreamReader ...
- Yii2 数据库Active Record(ORM)
ACTIVE RECORD(ORM) 参考:http://www.yiiframework.com/doc-2.0/guide-db-active-record.html namespace app\ ...
- sql INSERT语句
当我们需要向数据库表中插入一条新记录时,就必须使用INSERT语句. INSERT语句的基本语法是: INSERT INTO <表名> (字段1, 字段2, ...) VALUES (值1 ...
- APICloud框架--sublime使用自定义loader
官方的apploader调试器,只是有官方的一些模块,如果我们使用非官方的模块就要使用自定义loader进行调试.接下来就走一边sublime设置自定义loader的步骤 修改config.xml 打 ...
- 树形dp+贪心+增量法+排序——cf1241E(好题)
/* 给定一棵树,每个结点最多选和其相连的k条边,问使边权和最大的策略 dp[u][0|1]用来表示u没连父边|连了父边 时u子树下的最优解 如果u不和任意一个儿子连边,那么u下的收益是tot=sum ...
- 吉首大学校赛 A SARS病毒 (欧拉降幂)
链接:https://ac.nowcoder.com/acm/contest/925/A来源:牛客网 题目描述 目前,SARS 病毒的研究在世界范围内进行,经科学家研究发现,该病毒及其变种的 DNA ...