首页 \ 问答 \ Python-忽略特殊字符并仅匹配文本(Python- ignore special characters and match only text)

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
更新时间:2022-02-27 22:02

最满意答案

通常是的,令牌在每个请求中传递..除了应用程序可能使用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.

相关问答

更多
  • 最后我所做的是获得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}}语法进行访问。 我会用相似的例子向你演示相同的例子 ...
  • 通常是的,令牌在每个请求中传递..除了应用程序可能使用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不知道您的请求过滤器是身份验证验证程序,因此您无法在元数据页面中获取身份验证密钥图标以指示哪些服务 ...
  • 刷新令牌显示在与访问令牌不同的路径上:访问令牌仅呈现给资源服务器,刷新令牌仅呈现给授权服务器。 访问令牌可以是自包含的,因此它不需要昂贵的调用授权服务器来检查其有效性,但是为了减少损失并提高准确性(如果出现问题则不能撤销)它是短暂的。 刷新令牌是长期存在的,并且在每次调用授权服务器时都会得到验证,因此它可以被撤销。 两者的结合使系统安全。 The refresh token is presented on a different path than the access token: the access ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)