diff --git a/baidu-spider/main.py b/baidu-spider/main.py index d50d75fc4c1c872d60dbfc2098aebae67f71acc8..1f07eb7e5d5571dd457b462a18cd28091a5aab11 100644 --- a/baidu-spider/main.py +++ b/baidu-spider/main.py @@ -31,7 +31,7 @@ def extract_info(html): def save_data(filename, data): # open a file named as below, and file mode is append, `a` for short - with open(filename + ".txt", 'a') as f: + with open(filename + ".txt", 'a',encoding='utf-8') as f: # itrate the result from the data list for one_data in data: # write each line of data then end with a line breaker diff --git a/hello.txt b/hello.txt new file mode 100644 index 0000000000000000000000000000000000000000..c6a57595b5d097aefa1dff97597b36d381b26053 --- /dev/null +++ b/hello.txt @@ -0,0 +1,3 @@ +hello bro + im using vim to creat this txt. +