id = toupper(sapply(strsplit(srcFile, '[_.]'), '[[', 1)) 翻译成python
时间: 2023-04-01 11:01:21 浏览: 76
代码翻译成 Python 的形式为:
id = ''.join([word.split('.')[].split('_')[].upper() for word in srcFile.split('/')])
相关问题
解释一下这行代码 async Task<LoginResultModel> PasswordSignInAsync(IAuthenticationManager authenticationManager, LoginViewModel model) { var obj = new { l = model.Account, p = Security.Encrypt(model.Password) }; LogHelper.Debug(JsonHelper.SerializeObject(obj)); var content = SSOHelper.GetLoginInfo(model.Account, model.Password); var content1 = SSOHelper.GetLoginInfo1(model.Account, model.Password); LogHelper.Debug(content); LoginResultModel result = JsonHelper.DeserializeObject<LoginResultModel>(content); LoginResultModel result1 = JsonHelper.DeserializeObject<LoginResultModel>(content1); ExceptionHelper.TrueThrow(result == null, "登录结果为空,请联系管理员!"); ExceptionHelper.TrueThrow(result.code == 500, result.message); string username = result.result.user_info.user_name; string usercode = model.Account; string dutyname = result.result.user_info.duty_name; string groupname = result.result.user_info.group_name; string usernametest = result.result.user_info.user_name; var Information = result.result.user_info; string password = result1.result.access_token; OnlineHistory aa = new OnlineHistory() { GWMCode = usercode, GWMName = username, GWMDuty = dutyname, GWMGroupName = groupname, OnlineTime = DateTime.Now, }; int useInsertOnlineHistory = OnlineHistoryDAL.Instance.InsertOnlineHistory(aa); ClaimsIdentity _identity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie); _identity.AddClaim(new Claim(ClaimTypes.Name, username)); _identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, usercode)); _identity.AddClaim(new Claim(ClaimTypes.Role, dutyname)); _identity.AddClaim(new Claim(ClaimTypes.GroupSid, usercode)); _identity.AddClaim(new Claim(ClaimTypes.Actor, usernametest)); _identity.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity")); _identity.AddClaim(new Claim("DepartmentName", groupname)); _identity.AddClaim(new Claim("DutyName", dutyname)); _identity.AddClaim(new Claim("Password", password)); var Staffpermission = PermissionManageDAL.Instance.GetUersPermissionList(usercode.ToUpper()); var UseStaffpermission = Staffpermission.Select(m => new StaffPermissionItem { PermissionCode = m.PermissionCode }).ToList(); _identity.AddClaim(new Claim("Permissions", JsonHelper.SerializeObject(UseStaffpermission)));//用户的权限列表 authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = model.RememberMe }, _identity); return await Task.FromResult(result); }
这段代码的作用是进行登录操作。代码中的 `PasswordSignInAsync` 方法接受两个参数:`authenticationManager` 和 `model`。
在方法中,首先会创建一个匿名对象,包含账号和经过加密的密码。接着,使用 `SSOHelper.GetLoginInfo` 和 `SSOHelper.GetLoginInfo1` 方法获取登录信息,并使用 `JsonHelper.DeserializeObject` 将获取的信息反序列化为 `LoginResultModel` 类型的对象。然后,检查登录结果是否为空,或者返回码是否为 500。如果满足任意一个条件,就会抛出异常。
接下来,会创建一个 `ClaimsIdentity` 对象,并为其添加多个声明,包括用户名、用户代码、职位等信息。然后,使用 `PermissionManageDAL.Instance.GetUersPermissionList` 方法获取用户的权限列表,并将其添加为声明。最后,使用 `authenticationManager.SignIn` 方法登录用户,并返回登录结果。
str += str_temp.toUpper();
`str += str_temp.toUpper();` 是将字符串 `str_temp` 转换为大写形式,并将其追加到字符串 `str` 的末尾。
`str_temp` 是一个字符串变量,`toUpper()` 是 `QString` 类的成员函数,用于将字符串转换为大写形式。
`+=` 是字符串拼接的操作符,它将右侧的字符串连接到左侧的字符串上,并更新左侧的字符串。
因此,这行代码的作用是将 `str_temp` 转换为大写形式,并将其追加到字符串 `str` 的末尾,相当于将大写形式的 `str_temp` 添加到 `str` 中。