基础复习
Posted duhong0520
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基础复习相关的知识,希望对你有一定的参考价值。
#简述编程语言与语言之间的区别
# 1.# python简单,python开发效率快,python代码简介,python跨平台,python学习成本比较低
# 2.列举Python2和Python3的区别?
# py3:
# print()
# unicode
# 类:新式类
# range() -- 可迭代对象
# input() -- 获取的内容全都是字符串
# 除法 -- 浮点数
# readlines() -- 列表
# 没有long(长整型)
# py2:
# print
# ascii
# 类:金典类,新式类
# range() -- 列表
# xrange() -- 可迭代对象
# raw_input() -- 获取的内容全都是字符串
# input() “alex”
# 除法 -- 整数
# xreadlines -- 返回一个迭代器
# 3.
# 1 7
# 4. 两个列表,一个列表中是元组
# 5.
# a,b = b,a
# 6. 标准:三引号可以进行换行,单引号和双引号需要配合使用
# 7.
# is 判断的是两边的内存地址
# == 判断的是两边的值
# 8.
# tuple(list)
# list(tuple)
# 9.
# name=‘老男孩‘
# print(name[::-1])
# 10.两个set如何获取交集、并集、差集?
# &
# |
# -
# 11.那些情况下, y != x - (x-y)会成立?
# x = {2}
# y = {1}
# print(y != x - (x-y))
# 两个非空的集合,并且集合中的元素不能相同,并且也不能是x的子集
# 12.
# lst = [1,2,3,4,5,6,7]
# import copy
# lst3 = lst.copy() # 浅拷贝
# lst1 = copy.copy(lst) # 浅拷贝
# lst2 = lst[:] # 浅拷贝
# 13.
# 赋值: 多个变量指向同一内存地址
# a = 10
# b = a
# c = b
# a = 10 + 5
# print(a,b,c) # 15 10 10
# # 浅拷贝:
# lst = [1,2,3,4,[5,6,],78]
# lst1 = lst[:]
# lst1.append(0)
# print(lst1) # [1,2,3,4,[5,6,],78,0]
# print(lst) # [1,2,3,4,[5,6,],78]
# 浅拷贝:
# lst = [1,2,3,4,[5,6,],78]
# lst1 = lst[:]
# lst1[-2].append(0)
# print(lst1) # [1,2,3,4,[5,6,0],78,0]
# print(lst) # [1,2,3,4,[5,6,0],78]
# # 浅拷贝:
# lst = [1,2,3,4,[5,6,],78]
# lst1 = lst[:]
# lst1[-2] = 12
# print(lst1) # [1,2,3,4,12,78,0]
# print(lst) # [1,2,3,4,[5,6,0],78]
# 浅拷贝:
# lst = [1,2,3,4,[5,6,],78]
# lst1 = lst[:]
# lst[-2] = 12
# print(lst1) # [1,2,3,4,[5,6],78,0]
# print(lst) # [1,2,3,4,12,78]
# 浅拷贝: 只拷贝第一层元素的内存地址
# 深拷贝:
# import copy
# lst = [1,2,[3,4],5]
# lst1 = copy.deepcopy(lst)
# lst.append(10)
# print(lst) # [1,2,[3,4],5,10]
# print(lst1) # [1,2,[3,4],5,]
# import copy
# lst = [1,2,[3,4],5]
# lst1 = copy.deepcopy(lst)
# lst[-2].append(10)
# print(lst) # [1,2,[3,4,10],5,]
# print(lst1) # [1,2,[3,4],5]
# import copy
# lst = [1,2,[3,4],5]
# lst1 = copy.deepcopy(lst)
# lst[-2] = 52
# print(lst) # [1,2,52,5,]
# print(lst1) # [1,2,[3,4],5]
# import copy
# lst = [1,2,[3,4,[1,[]]],5]
# lst1 = copy.deepcopy(lst)
# lst[-2] = 52
# print(lst) # [1,2,52,5,]
# print(lst1) # [1,2,[3,4],5]
import copy
# dic = {"key":[12,23]}
# dic1 = dic.copy()
# dic["key"].append(15)
# print(dic)
# print(dic1)
# 深拷贝,不管嵌套多少层