标签:pre move 字符 去重 sde 代码 rem def 外壳
# str
# upper lower
# startswith endswith
# s = ‘Python世界‘
# print(s.upper())
# print(s.lower())
# print(s.startswith(‘P‘))
# print(s.endswith(‘界‘))
# replace
# msg = ‘zs 很厉害,zs王者打的很好‘
# msg1 = msg.replace(‘zs‘,‘ls‘)
# msg2 = msg.replace(‘zs‘,‘ls‘,1)
# print(msg1)
# print(msg2)
# strip
# s = ‘ \t弟弟\n‘
# print(s.strip())
# s = ‘qqw弟弟asd‘
# print(s.strip(‘asdqw‘))
# split
# s = ‘zs ls ww‘
# s1 = s.split()
# print(s1)
# s = ‘zs:ls:ww‘
# s2 = s.split(‘:‘)
# print(s2)
# s2 = ‘:zs:ls:ww‘
# s3 = s2.split(‘:‘)
# s4 = s2.split(‘:‘,2)
# print(s3)
# print(s4)
# join
# s = ‘zs‘
# s1 = ‘+‘.join(s)
# print(s1)
# s = [‘zs‘,‘ls‘,‘ww‘]
# s1 = ‘:‘.join(s)
# print(s1)
# format
# 格式化输出
# is系列
# name = ‘hcy123‘
# print(name.isalnum())
# print(name.isalpha())
# print(name.isdecimal())
# list
# 增
# l1 = [‘zs‘, ‘ls‘, ‘ww‘, ‘zl‘, ‘kk‘ ]
# append 追加
# l1.append(‘dd‘)
# print(l1)
# insert
# l1.insert(1,‘dd‘)
# print(l1)
# extend
# l1.extend(‘abcd‘)
# print(l1)
# 删
# l1 = [‘zs‘, ‘ls‘, ‘ww‘, ‘zl‘, ‘kk‘ ]
# pop
# l1.pop(2)
# print(l1)
# remove 删头一个
# l1.remove(‘ww‘)
# print(l1)
# clear
# l1.clear()
# print(l1)
# del
# del l1[-1]
# print(l1)
# del l1[::2]
# print(l1)
# 改
# 索引切片
# 查
# 索引切片
# tuple
# 元组的拆包
# a,b = (1,2)
# print(a,b)
# range
# dict
# 增
# dic = {‘name‘:‘zs‘,‘age‘:18}
# dic[‘sex‘] = ‘男‘
# print(dic)
# 有则改之 无则加之
# setdefault
# dic = {‘name‘:‘zs‘,‘age‘:18}
# dic.setdefault(‘sex‘,‘男‘)
# print(dic)
# 有则不变 无则加之
# 删
# pop
# dic = {‘name‘:‘zs‘,‘age‘:18}
# dic.pop(‘age‘)
# print(dic)
# 改
# 正常改
# 查
# get
# dic = {‘name‘:‘zs‘,‘age‘:18}
# l1 = dic.get(‘age‘)
# l2 = dic.get(‘sex‘,‘无‘)
# print(l1)
# print(l2)
# keys()
# dic = {‘name‘:‘zs‘,‘age‘:18}
# print(list(dic.keys()))
# values()
# dic = {‘name‘:‘zs‘,‘age‘:18}
# print(list(dic.values()))
# items()
# dic = {‘name‘:‘zs‘,‘age‘:18}
# print(dic.items())
# for a,b in dic.items():
# print(a,b)
id:返回地址
==:比较是否相等
is:比较地址是否一样
# 集合 无序
# set
# 空集合 set()
# 增
# set1 = {‘zs‘, ‘ls‘, ‘ww‘, ‘zl‘, ‘kk‘, ‘tt‘}
# add
# set1.add(‘dd‘)
# print(set1)
# updata 迭代着增
# set1.update(‘abcd‘)
# print(set1)
# 删
# set1 = {‘zs‘, ‘ls‘, ‘ww‘, ‘zl‘, ‘kk‘, ‘tt‘}
# remove
# set1.remove(‘ww‘)
# print(set1)
# pop 随机删除
# set1.pop()
# print(set1)
# 用于列表去重
# li = [1, 1, 2, ‘hhh‘, 2, 2, ‘hhh‘, 3, 4, 5, 6, ‘hhh‘, 6, 6]
# set1 = set(li)
# l1 = list(set1)
# print(l1)
标签:pre move 字符 去重 sde 代码 rem def 外壳
原文地址:https://www.cnblogs.com/szheng/p/13189753.html