Python学习基础(二)——集合 深浅拷贝 函数

集合

# 集合
'''
    集合是无序不重复的
'''

# 创建列表
l = list((1, 1, 1))
l1 = [1, 1, 1]
print(l)
print(l1)
print("**************")
# 创建集合
s = set('wjw')
print(s, type(s))
print("-----------------")

print(set("wjw"))

print("++++++++++++++++++")
print(set("wjwqwert") or set("wqeqmn"))
print(set("wjwqwert") and set("wqeqmn123"))

 

深浅拷贝

# 深浅拷贝

s = [1, 2, 3, 4, 5, 6]
s2 = s.copy()  # 将s拷贝给s2   s2与s独立,相互不干涉
print(s)
print(s2)
print("//////////////////////////")
s2[0] = 10
print(s)
print(s2)

print("***************************")
# 修改列表会相互影响
s4 = [[1, 2, 3], "wjw", "18"]
s3 = s4.copy()
s3[0][2] = 5
print(s3)
print(s4)

print("-------------------------------")

 

函数

def logger(log_text):
    print("这是一个log函数 %s" % log_text)


logger("张三")


s='''

参数:
    1. 必备参数
    2. 关键字参数
    3. 默认参数
    4. 不定长参数

'''
print(s)

 

posted @ 2018-03-27 12:32  我是ed  阅读(145)  评论(0编辑  收藏  举报