jeudi 29 octobre 2015

TypeError: expected a character buffer object in Python

I don't know why I can't write this document to file:

document=['', 'feeling frisky cool cat hits join us', 'askjoe app add music videos free today saintkittsandnevis', 'give dog flea bath midnight greeeeat smells like dawn', 'cat finds flash drive spent weeks looking', 'downside cat dude means can recognize nice smell pee second', 'louis pine apple make life brighter like star please follow me', 'gonna need nice cup coffee morning', 'gonna need nice cup coffee morning', 'iphone gives warning dies smh']

Here's the code for writing into the file:

with open("cleaned_tweet.txt", "w") as cleaned_tweet_file:
    cleaned_tweet_file.write(document)

Here's the error I get:

Traceback (most recent call last):
  File "test.py", line 85, in <module>
    cleaned_tweet_file.write(document)
TypeError: expected a character buffer object

Aucun commentaire:

Enregistrer un commentaire