I'm working on a python project and facing an issue, I have a snippet of code like bellow:
if published_to is not '*':
if 'T00:00:00.000Z' not in published_to:
published_to = published_to.replace('T00:00:00.000Z', '')
published_to = published_to.split('-')[::-1]
published_to = '-'.join(published_to) + 'T00:00:00.000Z'
And, the above code running like charm when I run my server on windows with python 2.7, but when I deploy the project to Ubuntu 16.04 with the same version of python it's running through the body of "if" statement no mater published_to
equal to *
or not. So, could anyone please tell me the reason???
If you want to check whether published_to
is equal to '*'
or not, then use !=
:
if published_to != '*':
Using is not
checks object identity , which is a stronger test than equality and not what you are looking for here. (Basically, you can have two different string objects that contain the same text - different objects, but they're equal ).
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.