Skip to content

Commit

Permalink
Use io.open and utf8 encoding to fix UnicodeDecodeError for Python3 (k…
Browse files Browse the repository at this point in the history
  • Loading branch information
yang-zhang authored and fchollet committed Dec 10, 2017
1 parent 5e68252 commit a04c41a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/lstm_text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
import numpy as np
import random
import sys
import io

path = get_file('nietzsche.txt', origin='https://s3.amazonaws.com/text-datasets/nietzsche.txt')
text = open(path).read().lower()
text = io.open(path, encoding='utf-8').read().lower()
print('corpus length:', len(text))

chars = sorted(list(set(text)))
Expand Down

0 comments on commit a04c41a

Please sign in to comment.