目的:proxy_1-0-58-BRANCH ---> proxy1.0.58
- python
# python
_str='proxy_1-0-58_BRANCH'
''.join('.'.join(_str.split('-')).split('_'))[:-6]
切片函数split(str="", num=string(count(str)))
_str.split('-', 1) #['proxy_1', '0-58-BRANCH']
切片对象 class slice(start, stop[, step])
myslice = slice(2)
_list = [1,2,3,4]
print _list[myslice] # 1,2
- SHELL
# shell
_str='proxy_1-0-58_BRANCH'
echo ${_str:0:-6} | sed 's\-\.\g' | sed 's\_\\g'
sed使用:插入删除替换文本
https://www.jb51.net/article/56563.htm
https://www.cnblogs.com/kinga/p/5772566.html
网友评论