I have this large string value, about 500 characters called 'strPage6' I'm looking to see if nth position of this string has the '%' value with an if statement without success.
#see if 330th character has value '%'
if (strPage6[330:331]=="%"):
print("330th character is '%' ")
print(strPage6)
else:
print("330th character is NOT '%' ")
print(strPage6)
my terminal returns the following value:
330th character is NOT '%'
b'%'
I tried switching the byte string into a plain string with 'decode' with the following result:
strPage6=strPage.decode('utf-8')
[...]
330th character is NOT '%'
e
Basically, I am looking to get the following result:
330th character is '%'
%
Your help is appreciated!
Did you try strPage6[330]==b"%"? – khelwood
does the equation properly
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.