How do I handle this?
wfile.write(data['text']+'\n')
UnicodeEncodeError: 'cp949' codec can't encode character
import tweepy
import time
import os
import json
search_term1 = ''
search_term2 = ''
lat = ""
lon = ""
radius = ""
location = "%s,%s,%s" % (lat, lon, radius)
auth = tweepy.OAuthHandler(API_key, API_secret)
auth.set_access_token(Access_token, Access_token_secret)
api = tweepy.API(auth)
c=tweepy.Cursor(api.search,
q="{}+OR+{}".format(search_term1, search_term2),
rpp=1000,
geocode=location,
include_entities=True)
wfile = open(os.getcwd()+"/test1.txt", mode='w')
data = {}
i = 1
for tweet in c.items():
data['text'] = tweet.text
print(i, ":", data)
wfile.write(data['text']+'\n')
time.sleep(0.5)
i += 1
wfile.close()
I get this error by modifying the Internet.
TypeError: write() takes no keyword arguments
wfile.write(data['text']+'\n',encoding='UTF8')
TypeError: write() takes exactly one argument (2 given)
wfile.write(data['text']+'\n','utf-8')