python入门9 (字符串)
摘要:1.字符串的内容对齐操作 s = 'hello,Python' '''居中对齐''' print(s.center(20,'*')) '''左对齐''' print(s.ljust(20,'*')) print(s.ljust(10)) print(s.ljust(20)) '''右对齐''' pr
阅读全文
posted @
2021-12-15 00:20
从精通到陌生
阅读(53)
推荐(0) 编辑
python入门8 (字符串)
摘要:1.字符串的创建和驻留机制 a='python' b="python" c='''python''' print(a,id(a)) print(b,id(b)) print(c,id(c)) 2.字符串的查找 '''字符串的查找操作''' s='hello,hello' print(s.index(
阅读全文
posted @
2021-12-08 00:12
从精通到陌生
阅读(43)
推荐(0) 编辑
python入门7(集合)
摘要:1.集合的创建方式 #集合的创建方式 '''第一种创建方式使用{}''' s={2,3,4,5,5,6,7,7} #集合中的元素不允许重复 print(s) '''第二种创建方式使用set()''' s1 =set(range(6)) print(s1,type(s1)) s2=set([1,2,4
阅读全文
posted @
2021-12-07 00:02
从精通到陌生
阅读(64)
推荐(0) 编辑
python入门6 (元组)
摘要:1.什么是元组 2.元组的创建方式 '''第一种创建方式,使用()''' t=('Python','world',99) print(t) print(type(t)) t2='Python','world',99 print(t2) print(type(t2)) t3=('Python',) #
阅读全文
posted @
2021-12-01 00:07
从精通到陌生
阅读(98)
推荐(0) 编辑