def supplement_list(list,supplementList,supplementListPos):
"""
补充列表:将需要补充的信息按位置补充完成
定义声明位置数值(temp_list_pos)的数值和长度(数值为50+长度和全列表长度相同)
两个列表对应比较(全列表+补充列表)
全列表和补充列表中都存在一个数值,位置数值(temp_list_pos)对应的数值取原补充数值
返回数值:全列表+位置数值列表
缺点:全列表中与补充列表相同的数值不能重复
用时:1.185185653406678e-05
"""
temp_list_pos = [50]*len(list)
for i in range(len(list)):
for j in range(len(supplementList)):
if list[i] == supplementList[j]:
temp_list_pos[i] = supplementListPos[i]
break
return list,temp_list_pos
if __name__ == '__main__':
list = [1, 2, 3, 4, 5, 4]
supplementList = [1, 2, 3]
supplementListPos = ['a', 'b', 'c']
supplement_list(list, supplementList, supplementListPos)
优化函数(O(n*n)-->O(n))(用时:2.0543217992382415e-05)
获取列表的index可以中遍历的方式,也可以中index的方式
def supplement_list(list_key,supplement_list_key,supplement_list_value):
temp_list_value = [50]*len(list_key)
for i in range(len(list_key)):
if list_key[i] in supplement_list_key:
b_index=supplement_list_key.index(list_key[i]) #(按数值去找index:少去一个循环)
temp_list_value[i] = supplement_list_value[b_index]
return list_key,temp_list_value
update数据库中实体的属性
select @rid from v_patient where name == '7bef992b222aab683113ac2b3163386c64337edaadf4cfd0c853998e098badda'
获取rid之后用update的方法,更新加入新的元素就好
rids = client.command("select @rid from v_patient where name == '7bef992b222aab683113ac2b3163386c64337edaadf4cfd0c853998e098badda'")
for rid in rids:
print(rid.rid)
client.command("UPDATE {} SET gender='female' RETURN AFTER @rid".format(rid.rid))
"""
补充列表:将需要补充的信息按位置补充完成
定义声明位置数值(temp_list_pos)的数值和长度(数值为50+长度和全列表长度相同)
两个列表对应比较(全列表+补充列表)
全列表和补充列表中都存在一个数值,位置数值(temp_list_pos)对应的数值取原补充数值
返回数值:全列表+位置数值列表
缺点:全列表中与补充列表相同的数值不能重复
用时:1.185185653406678e-05
"""
temp_list_pos = [50]*len(list)
for i in range(len(list)):
for j in range(len(supplementList)):
if list[i] == supplementList[j]:
temp_list_pos[i] = supplementListPos[i]
break
return list,temp_list_pos
if __name__ == '__main__':
list = [1, 2, 3, 4, 5, 4]
supplementList = [1, 2, 3]
supplementListPos = ['a', 'b', 'c']
supplement_list(list, supplementList, supplementListPos)
优化函数(O(n*n)-->O(n))(用时:2.0543217992382415e-05)
获取列表的index可以中遍历的方式,也可以中index的方式
def supplement_list(list_key,supplement_list_key,supplement_list_value):
temp_list_value = [50]*len(list_key)
for i in range(len(list_key)):
if list_key[i] in supplement_list_key:
b_index=supplement_list_key.index(list_key[i]) #(按数值去找index:少去一个循环)
temp_list_value[i] = supplement_list_value[b_index]
return list_key,temp_list_value
update数据库中实体的属性
select @rid from v_patient where name == '7bef992b222aab683113ac2b3163386c64337edaadf4cfd0c853998e098badda'
获取rid之后用update的方法,更新加入新的元素就好
rids = client.command("select @rid from v_patient where name == '7bef992b222aab683113ac2b3163386c64337edaadf4cfd0c853998e098badda'")
for rid in rids:
print(rid.rid)
client.command("UPDATE {} SET gender='female' RETURN AFTER @rid".format(rid.rid))