Wednesday, 15 July 2015

python - Resolving TypeError str doesn't support the buffer API -


I am trying to match the following code, but I run in a TypeError: type str buffer is not supported API does How can this be solved?

  file = open ("C: \\ user \\ sagars \\ desktop \\ newips.json", "rb") i = 0 y = "not for line in file" Information available for "IP": z = line print (z) if y in z: print ("can not be parsed") Other: print ("can pars!")  
< / Div>

You are reading the file as binary (instead of 'rb' which is probably messing it up) This code snippet is slightly more idiotic:

  open As ('C: \\ user \\ sagars \\ desktop \\ newips.json', 'r') f: line = F.readline () if y in line: print ("can not be parsed ") And: print (" can pars! ")  

No comments:

Post a Comment