glob
1、import glob #导入整个glob模块
2、from glob import golb #从glob模块导入glob函数
”*”匹配0个或多个字符;
”?”匹配单个字符;
”[]”匹配指定范围内的字符,如:[0-9]匹配数字。
https://zhuanlan.zhihu.com/p/71861602
https://blog.csdn.net/gufenchen/article/details/90723418
sort
https://blog.csdn.net/robinson_/article/details/51484147
https://blog.csdn.net/qq_41468616/article/details/121143989
函数 sort()用于列表中元素的排序
list.sort() 不会返回对象,会改变原有的list
(这点与sorted()不同,sorted()函数会返回一个列表,而sort()函数是直接在原来的基础上修改,其次注意语法)
range
range(10) # 从 0 开始到 9
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
range(1, 11) # 从 1 开始到 10
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
pickle 文件
https://blog.csdn.net/weixin_45564943/article/details/121535399
with as
https://blog.csdn.net/qiqicos/article/details/79200089
每次摩擦的抓地力:20*40
with open(good_grasp_file_name + ".pickle", "wb") as f:
以二进制格式打开一个文件只用于写入。如果该文件已存在则将其覆盖。如果该文件不存在,创建新文件。
pickle.dump(good_grasp, f)
https://blog.csdn.net/weixin_39641257/article/details/110488167
https://blog.csdn.net/qq_41468616/article/details/121143989
def do_job(i):
object_name = file_list_all[i].split("/")[-1]
#split("/")[-1]的作用: 以‘/ ’为分割符,保留最后一段
#https://blog.csdn.net/wuliangcai_/article/details/86004226
good_grasp = multiprocessing.Manager().list()
p_set = [multiprocessing.Process(target=worker, args=(i, 100, 20, good_grasp)) for _ in
range(50)] # grasp_amount per friction: 20*40
[p.start() for p in p_set]
[p.join() for p in p_set]
good_grasp = list(good_grasp)
if len(good_grasp) == 0:
return
good_grasp_file_name = "./generated_grasps/{}_{}_{}".format(filename_prefix, str(object_name), str(len(good_grasp)))
with open(good_grasp_file_name + ".pickle", "wb") as f:
pickle.dump(good_grasp, f)
tmp = []
for grasp in good_grasp:
grasp_config = grasp[0].configuration
score_friction = grasp[1]
score_canny = grasp[2]
tmp.append(np.concatenate([grasp_config, [score_friction, score_canny]]))
np.save(good_grasp_file_name + ".npy", np.array(tmp))
print("finished job ", object_name)
np.round()
取整,保留几位小数
https://blog.csdn.net/m0_49475842/article/details/108867547
https://blog.csdn.net/m0_53392188/article/details/119742913
enumerate() 函数
for index,xx in enumerate()
https://www.runoob.com/python/python-func-enumerate.html
return
return返回后后面的都不执行了
logging.debug
https://blog.csdn.net/lxy210781/article/details/89441539
https://blog.csdn.net/weixin_39862484/article/details/110345318
https://blog.csdn.net/RNG_uzi_/article/details/108952628
break continue
控制本层循环
log debug
https://zhuanlan.zhihu.com/p/454463040
python 列表相加
pcl= [1,2,3]
pcl1=[4,5,6]
pcl1=pcl1+pcl
print(pcl1)
456123 加在了后面
字典
它实际做的就是 [A, [B,C] ] 把 A 和 [B,C] 拼接了是吧 他后面的只是直接拿【 】 把 b和c 两个数字拼起来了
window
d:
cd d:\ 路径