为什么str.lower()修改修改字符串comp
我不明白为什么要获得这些不同的结果,因此我有以下python代码剪切,并且已经发疯了。任何人都可以详细说明吗?
test = "GTX1050Ti 4GB"
print(test)
if "gtx" and "560" and "ti" in test:
print("GTX 560 Ti")
else:
print("nope")
print(test.lower())
if "gtx" and "560" and "ti" in test.lower():
print("GTX 560 Ti")
else:
print("nope")```
Output:
GTX1050Ti 4GB
nope
gtx1050ti 4gb
GTX 560 Ti
I have the following python code snipped and have been getting insane as i don't understand why I'm getting these different results. Can anyone elaborate?
test = "GTX1050Ti 4GB"
print(test)
if "gtx" and "560" and "ti" in test:
print("GTX 560 Ti")
else:
print("nope")
print(test.lower())
if "gtx" and "560" and "ti" in test.lower():
print("GTX 560 Ti")
else:
print("nope")```
Output:
GTX1050Ti 4GB
nope
gtx1050ti 4gb
GTX 560 Ti
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
所有
来帮助确保满足所有检查的条件,然后如果需要更改所检查的内容,则只需要在一次位置进行操作即可。
You can use
all
to help ensure the condition is met for all checksThen if you need to change what is checked, you only need to do it in once place.