-1
import nltk
from urllib import request

url = "http://www.site.uottawa.ca/~diana/csi5386/A1_2020/microblog2011.txt"
response = request.urlopen(url)
raw = response.read().decode('utf8')
tokens = nltk.word_tokenize(raw)
tokens

In the above code the output is in 'tokens' in the form of list. How to copy this list into a text file?

2

1 Answer 1

1

You would need to do something like this:

with open('filename.txt', 'w') as f:
    for i in tokens:
        f.write(i)  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.