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