1.split和join()
a="zz.yy.hh"
b=a.split(".")
c=".".join(b[1:])
print(b)
print(c)
##############
['zz', 'yy', 'hh']
yy.hh
2.把list扩展成两倍:
a=['a','b']
b=int(2)*a
print(b)
################
['a', 'b', 'a', 'b']
3.dicts存储在list里面:
self.files = []
for name in self.img_ids:
img_file = osp.join(self.root, "images/%s" % name)
label_file = osp.join(self.root, "labels/%s" % name)
self.files.append({"img": img_file, "label": label_file,"name": name})
4.这个可以很好的将一个多维数组里面的特定的值映射成我们需要的值,特别是在做segmentation的时候,处理数据集label的标签时,尤为重要。将c[[True,False],[False,True] ]中为bool值为True的,转为特定的value
import numpy as np
c=np.array([[5,4],[5,4]])
c[c==4]=1
print(c)
############
[[5 1]
[5 1]]