python - why pycharm gives a wrong condition check? -


i have string read file, there cases readline() return blank line , need check that, please see screenshot below , appreciated if can explain me why gives wrong result:

enter image description here

as can see screenshot, line='\n', why expression's evaluation result false?

there sure alternative way check blank line, curiously wanting know why script not working.

thank you.

thanks.

your input file contains nasty characters, "zero width space" or "invisible separator". can output these if print (or evaluate) repr(line):

with open('data.txt', 'w') f:     f.write(u"\n")     f.write(u"\u200b\n")  # 0 width space     f.write(u"\u2063\n")  # invisible separator     f.write(u"\n")   open('data.txt', 'r') f:     line in f:         print(repr(line)) 

if debug above, able replicate behaviour lines 2 , 3, not lines 1 , 4. note these characters not visible in fonts (they not take space!), , printing/displaying them (as hovering in debugger) not reveal there.

in "evaluate expression" dialog in pycharm, simple evaluate "repr(line)" see what's in it.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -