一、新建python文件的自定义注释说明:
# -*- coding: utf-8 -*-
# @Time : ${DATE} ${TIME}
# @Author : zys
# @File : ${NAME}.py
# @Software: PyCharm
# @contact: 120079155@qq.com
# -*- 功能说明 -*-
#
# -*- 功能说明 -*-
二、自定义代码块
从File-》Setting-》Editor-》Live Templates-》Python进入代码片段编辑界面。
示例,删除函数模板:
def Delete(_d_info:"参数信息"):
d_result = {}
d_result["error"] = "ok"
d_result["errorDetail"] = ""
if len(_d_info)>0:
if "select_id" in _d_info.keys() and _d_info["select_id"]!="":
l_selectID=_d_questInfo["select_id"].split(",")
l_ID_List=[i for i in l_selectID if i !='']
if len(l_newList)>0:
#QuestionBank.objects.filter(id__in=l_ID_List).delete()
$END$
d_result["error"] = "no"
d_result["errorDetail"] = "删除操作成功"
else:
d_result["errorDetail"] = "ID错误"
else:
d_result["errorDetail"] = "删除条件获取错误"
else:
d_result["errorDetail"] = "删除信息获取错误"
return d_result
然后需要调用时:
CTRL+j 查找命名的文件,然后就可以插入刚定义的代码段了。