
关于python[:-1][::-1]的理解
[:-1]
正序数列,删除最后一个
eg:a=”hello”
a[:-1]
输出:“hell”
###[::-1]
倒序数列
eg: a=”hello”
a[::-1]
输出:“olleh”
.lstrip()
删除头部某个符号
eg:a=[012]
a.lstrip(“0”)
输出:[12]
.rstrip()
删除尾部某个符号
eg:a=[012-]
a.rstrip(“-“)
输出:[012]
dic{}
dic.values() 是指字典中的值 冒号后面的
dic.keys() 是指字典中的键 冒号之前的
dic 是指字典中键和值都有
split()
切分 eg:s=[hello world]
s=s.split(“ “)
输出 s=[‘hello’,’world’]
join()
合并 eg: s=[‘hello’,’world’]
s=’-‘.join(s)
输出 s=[hello-world]




近期评论