When I run the code:
def test(string):
return '' in string
test("wolf")
It returns True
. What does ''
mean? I previously thought it meant nothing, but am now unsure. If it was nothing/ None
/ Null
then why does this expression return True
?
The return
expression (in this case) returns whether or not a string, int, float, etc. is in your variable. In this case, your string is not empty because '' simply means your answer has (or is) a string.
In other words, ''
does not equal None
.
print('' == None)
-> False
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.