my_tuple = ("张三",18,70)
print(my_tuple[2])
print(my_tuple.index(18))
print(my_tuple.count(70))
single_tuple_1 = (5)
print(type(single_tuple_1))
single_tuple_2 = (5,)
print(type(single_tuple_2))
print(len(my_tuple))
for i in my_tuple:
print(i,end=" ") """遍历元组"""
print("%s年龄是%d 身高是%.2f"%(my_tuple))
xiaoming = {"name" : "xiaoming"}
print(xiaoming["name"])
print(xiaoming)
xiaoming["age"] = 18
print(xiaoming)
xiaoming["age"] = 17
print(xiaoming)
xiaoming.pop("name")
print(xiaoming)
print(len(xiaoming))
temp = {"hight":"1.75"}
xiaoming.update(temp)
print(xiaoming)
for k in xiaoming:
print("%s %s"%(k,xiaoming[k])) """ 输出age 17
hight 1.75 """
xiaoming.clear()
print(xiaoming)
str1 = "hello world"
str2 = '我是"shui"'
print(str2)
for c in str2:
print(c,end=" ")
print()
str = "hello hello"
print(len(str))
print(str.count("hello"))
print(str.index("llo"))
print(str.__contains__("llo"))
my = "hello world"
print(my.startswith("hell"))
print(my.find("lloa"))
print(my.find("llo"))
my1 = my.replace("world","python")
print(my)
print(my1)
a = my.split()
print(a)
print(a[0])
res ="x".join(a)
print(res)
qq = "0123456789"
print(qq[2:6]) """ 输出2号元素,到6号元素,包含2号,不包含6号
输出结果 2345"""
print(qq[::2]) """ 从0号开始,每两个输出一个
输出结果 02468 """
print(qq[1::2])""" 从1号开始,每两个输出一个
输出结果 13579 """
print(qq[2:-1]) """从2号开始,输出到最后一个(-1),负几就是倒数第几个(不包含右边界)
输出 2345678 """
print(qq[-2:])
print(qq[::-1])
qa = [1,2]
sx = [3,4]
qa.extend(sx)
print(qa)
print(qa+sx)
qa.append(0)
print(qa)
qa.append(sx)
print(qa)