2

The python code:

sku_specs = "./item_specs.txt"

def item_specs():

    g = open(sku_specs,"r")
    lines = g.readlines()
    lines = "<br />".join(lines)
    return lines

f = open("ouput.txt","a")
f.write("Some stuff"+item_specs()+"more stuff")
f.write("more stuff")
f.close()

The extra characters that show up even if the file is "blank" are 

When I open the file in Notepad++ and "show all symobls" I still get these BOM characters when the .txt file appears to be blank.

Related: How do I remove  from the beginning of a file?

Is it as simple as lines.replace("","") ? Or is there something I am missing?

One Solution:

    lines = lines.decode("utf-8-sig")
    lines = lines.encode('utf-8','ignore')
Community
  • 1
  • 1
jmunsch
  • 22,771
  • 11
  • 93
  • 114

0 Answers0