我有一个字符串
package main
import "fmt"
func sum(a []int, c chan int) {
sum := 0
for _, v := range a {
sum += v
}
c <- sum // send sum to c
}
func main() {
a := []int{7, 2, 8, -9, 4, 0}
c := make(chan int)
go sum(a[:len(a)/2], c)
go sum(a[len(a)/2:], c)
x, y := <-c, <-c // receive from c
fmt.Println(x, y, x+y)
}
和一个清单
item1="Act the way that the people around you are acting."
表示if条件,
list1=['Act the way that the people around you are acting.', "This phrase might come in handy when you're traveling abroad notice that people do things differently than you're used to."]
它总是失败,但字符串存在于列表中。请帮忙
if item1 in list1:
print(item1)
在list1中看到此item1未获得True,请帮助
答案 0 :(得分:0)
我尝试了以下代码(编辑以查看长行),
item1="Act the way that the people around you are acting."
list1=['Act the way that the people around you are acting.',
"This phrase might come in handy when you're traveling abroad " +
"notice that people do things differently than you're used to."]
if item1 in list1:
print(item1)
并打印
按照你周围的人的行事方式行事。
因此,问题出在其他地方。
代码的第一部分df1,
不是有效的Python代码(可能是问题出在哪里)。编辑您的帖子,以便它是一个最小,完整且可验证的示例(https://stackoverflow.com/help/mcve)。
答案 1 :(得分:0)
我认为item1
肯定不在list1
中,否则会进入if
声明。我会打印出item1
和list1
的值来查看错误。如果你能给我两个数据帧的确切值,我可以帮助你。代码编写得非常糟糕