的子我知道计数列表项的简单事件一样简单: >>>[1, 2, 3, 4, 1, 4, 1].count(1)
3
但我想知道怎么做是计数每次一个字符串出现在列表条目的一个子字符串中。 例如,我想看看foo多少次出现在列表中data: data = ["the foo is all fooed", "the bar is all barred", "foo is now a bar"]
这
我已经阅读了How do you tell if a string contains another string in Unix shell scripting?,但我正在努力让我的代码以此为例工作。 我在默认的FreeBSD shell/bin/sh中这样做。请不要bash回答。 这里是我的代码 while
: ${start=$i}
var1="$(comma