# -*- coding: utf-8 -*- import dingtalk.api def jobid(userid_list,accesstoken): req = dingtalk.api.OapiSmartworkHrmEmployeeListRequest( "https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/list") user_dict = {} for i in range(0,len(userid_list),50): userranges = userid_list[i:i+50] req.userid_list=",".join(userranges) try: resp= req.getResponse(accesstoken)["result"] for user in resp: # userid = user["userid"] field_list = user["field_list"] JobNumber = "" UserName = "" for field in field_list: # print(field) if field["field_code"] == "sys00-name": UserName = field["value"] if field["field_code"] == "sys00-jobNumber": JobNumber = field["value"] JobNumber = JobNumber.replace(" ","") user_dict[JobNumber] = UserName except Exception as e: print(e) return user_dict