python学习07:列表复制
发布日期:2021-05-06 17:28:38 浏览次数:14 分类:技术文章

本文共 420 字,大约阅读时间需要 1 分钟。

from _ast import In#!/usr/bin/python# -*- coding: utf-8 -*-'''将一个列表的数据复制到另一个列表中'''def test1():    a=[1,2,3,4,5,6,7,8,9]    b=a.copy()    print(b)  def test2():    a=[1,2,3,4,5,6,7,8,9]    b=[]    for i in range(len(a)):        b.append(a[i])    print(b)   def test3():    a=[1,2,3,4,5,6,7,8,9]    b=[i for i in a]    print(b)     def test4():    a=[1,2,3,4,5,6,7,8,9]    b=a[:]    print(b)   test1()test2()test3()test4()
上一篇:python学习08:乘法表
下一篇:python学习06:斐波那契数计算

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年03月22日 06时38分25秒