Python-忽略特殊字符并仅匹配文本(Python- ignore special characters and match only text)
我正在尝试检查一个字符串是否存在于列表中:
我的字符串没有像{,},\ n,\ n \ n这样的特殊字符
string1='hi' string2='I' string3='am new to this'
作为我的列表条目包含像字符串:
list_count="{hi}","\n I","am \n new {to} this\n\n"
我想知道如何通过仅考虑列表的“文本部分”来检查字符串匹配
注意:我有n个字符串来检查列表
我已经尝试了下面的代码,似乎没有工作我的目的
字符串=字符串1,字符串,STRING3
码:
for i in strings: if i in list_count: print('yes')
我希望输出结果为是,例如:
if 'hi' in list_count:
它必须通过仅检查文本部分而不包括“{”'}“来打印”是“
I am trying to check if a string exists in list:
My string is without any special characters like {,},\n,\n\n
string1='hi' string2='I' string3='am new to this'
where as my list entry contains strings like:
list_count="{hi}","\n I","am \n new {to} this\n\n"
I want to know how can i check for a match of strings by considering only the "text part" of list
Note: I am having n number of strings to check in list
I have tried below code, seems to not work my purpose
strings=string1,string2,string3
code:
for i in strings: if i in list_count: print('yes')
I want the output to be yes for checks like:
if 'hi' in list_count:
It has to print yes by only checking for text part and not including '{' '}'
原文:https://stackoverflow.com/questions/50388786
最满意答案
通常是的,令牌在每个请求中传递..除了应用程序可能使用cookie等...也管理会话.. OAuth应该让你了解它如何工作在高水平...我发现学习闪烁和亚马逊的api也很有用。我所使用的应用程序使用这种机制并使用cookie存储一些额外的信息(我认为它使用了Web视图......)。 会话可以存储在您的后端。
Usually yes the token is passed in every request.. In addition to that apps may use cookies etc...to manage sessions as well.. OAuth should give you some sense of how this works at a high level... I have found studying api of flicker and amazon useful as well.. An application that I have worked on uses this mechanism and stores some additional info using cookies (I think it used web views..). The session can be stored in your back-end.
相关问答
更多-
在JWT身份验证令牌中验证来自请求的IP是否受理索赔(Validate IP from request against claim in JWT authentication token)[2022-06-24]
最后我所做的是获得IP。 然后我添加一个ActionFilterAttribute重写OnActionExecuting 在该过滤器中,我从Claim中获取原始IP,并将其与请求IP( context.HttpContext.Connection.RemoteIpAddress )进行比较。 In the end what I did was this to get the IP. Then I add an ActionFilterAttribute overrideing OnActionExecuti ... -
我将从#2开始: 使用基于令牌的身份验证有什么好处? 由于没有登录的概念,请求之间不需要维护状态,使用基本身份验证的简单密钥会不会更容易? 基本的auth用户名和密码: 也是一种象征。 实际上并没有“登录你”。 它以同样的方式是无状态的,因为用户名和密码随每个请求传递。 因此,在这种情况下,您所描述的令牌与密码之间的区别在于令牌的生命周期。 听起来你可能实际上有2个令牌。 一个用于执行请求(访问令牌),另一个用于请求新访问令牌(如果它们已过期)(刷新令牌)。 为什么这样? 一个想法是刷新令牌是最危险的,因为 ...
-
Postman在制作API请求时允许您使用各种选项。 在您的情况下,您可以通过以下方式为您的令牌创建一个全局变量: var jsonData = JSON.parse(responseBody); postman.setGlobalVariable('token', jsonData.token); 这将在您的Tests选项卡中,以便在您的请求完成后执行此脚本。 现在,设置了一个全局变量token ,并且可以在您进行的以下API请求中使用{{token}}语法进行访问。 我会用相似的例子向你演示相同的例子 ...
-
在基于令牌的身份验证中,是否在每个请求上提供了令牌?(In token based authentication, is the token provided on every request?)[2023-04-18]
通常是的,令牌在每个请求中传递..除了应用程序可能使用cookie等...也管理会话.. OAuth应该让你了解它如何工作在高水平...我发现学习闪烁和亚马逊的api也很有用。我所使用的应用程序使用这种机制并使用cookie存储一些额外的信息(我认为它使用了Web视图......)。 会话可以存储在您的后端。 Usually yes the token is passed in every request.. In addition to that apps may use cookies etc...to ... -
$ rootScope是一个将在页面刷新时消失的变量。 因此,我建议你使用cookie或sessionStorage。 当用户关闭他/她的浏览器选项卡时,SessionStorage将消失。 如果这不是首选案例,那么使用cookie。 要为$ http请求添加默认标头验证器,请使用拦截器,您可以在此处找到有关此文档的文档: 拦截器文档 拦截器的代码如下所示: $httpProvider.interceptors.push(function($q, $cookies) { return { ...
-
我不完全确定你的问题需要什么,但这是猜测。 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://rest.u.rl/do/this"]; NSString *header = [NSString stringWithFormat:@"%@",token]; //format as needed [request setValue:header forHTTPHeade ...
-
在“函数”中,不通过“应用程序设置”配置ASP.NET WebHook接收器信息。 当您创建WebHook功能时,我们会在功能应用程序中的自己的轻量级秘密存储中生成并存储配置。 我们这样做是为了避免在添加此类功能时的站点重启成本。 例如,如果您从我们拥有的GitHub WebHook模板(C#或Node)开始,您将看到这一点。 我们向您提供了Develop选项卡UI中所需的触发器URL和GitHub秘密。 即使函数运行时使所有ASP.NET WebHook接收器可用(我们在运行时注册它们),我们的UI和模板 ...
-
由于您没有使用ServiceStack的内置OAuth提供程序或后端UserAuth存储库,因此我倾向于使用选项1,因为它具有最少的移动部件,其中基本上基于令牌的身份验证只是验证请求过滤器 - 最终也是ServiceStack的[Authenticate]请求过滤器属性在幕后虽然更复杂,因为它与ServiceStack的AuthProvider模型集成在一起。 2之间的主要区别在于,由于ServiceStack不知道您的请求过滤器是身份验证验证程序,因此您无法在元数据页面中获取身份验证密钥图标以指示哪些服务 ...
-
在基于令牌的身份验证中使用Refesh令牌是安全的吗?(Using Refesh Token in Token-based Authentication is secured?)[2023-09-02]
刷新令牌显示在与访问令牌不同的路径上:访问令牌仅呈现给资源服务器,刷新令牌仅呈现给授权服务器。 访问令牌可以是自包含的,因此它不需要昂贵的调用授权服务器来检查其有效性,但是为了减少损失并提高准确性(如果出现问题则不能撤销)它是短暂的。 刷新令牌是长期存在的,并且在每次调用授权服务器时都会得到验证,因此它可以被撤销。 两者的结合使系统安全。 The refresh token is presented on a different path than the access token: the access ...