相关疑难解决方法(0)

检查另一个字符串中是否存在多个字符串

如何检查数组中的任何字符串是否存在于另一个字符串中?

喜欢:

a = ['a', 'b', 'c']
str = "a123"
if a in str:
  print "some of the strings found in str"
else:
  print "no strings found in str"
Run Code Online (Sandbox Code Playgroud)

该代码不起作用,只是为了展示我想要实现的目标.

python arrays string exists

338
推荐指数
6
解决办法
28万
查看次数

检查以确保字符串不包含多个值

**注意 - 我不只是在字符串的末尾进行测试 - 需要在字符串中的任何位置找到特定的子字符串

检查以确保字符串不包含多个值的最快方法是什么.我目前的方法是低效和unpythonic:

if string.find('png') ==-1 and sring.find('jpg') ==-1 and string.find('gif') == -1 and string.find('YouTube') == -1:
Run Code Online (Sandbox Code Playgroud)

python string algorithm

7
推荐指数
2
解决办法
4008
查看次数

标签 统计

python ×2

string ×2

algorithm ×1

arrays ×1

exists ×1