Split function add: \xef\xbb\xbf…\n to my list

后端 未结 3 841
予麋鹿
予麋鹿 2020-11-28 07:05

I want to open my file.txt and split all data from this file.

Here is my file.txt:

some_data1 some_data2 some_data3 some_da         


        
3条回答
  •  情歌与酒
    2020-11-28 07:53

    As the others mentioned, you are dealing with a file that contains UTF-8 BOM at its beginning.

    They all tell you how to deal with it or removing it directly.

    BUT, if you do happen to have to work with only one static file (or a small static set of them), you may wish to actively remove the BOM altogether so you simply don't have to deal with it.

    As a matter of fact, most text editors will allow you to convert from one encoding to another and sometimes UTF-8 and UTF-8 with BOM are listed separately.

    The first that comes to my mind (but there is many) is Notepad++. Simply go in Encoding > Convert to UTF-8 without BOM, save the file and you are set.

提交回复
热议问题