If you are using Python 2.6 or higher, you can use the io.StringIO
class after having read your file into memory (using the read() method). Example:
>>> import io
>>> s = u"a
b
c
d"
>>> sio = io.StringIO(s, newline=None)
>>> sio.readlines()
[u'a
', u'b
', u'c
', u'd']
To actually use this in your django view, you may need to convert the input file data to unicode:
stream = io.StringIO(unicode(request.FILES['foo'].read()), newline=None)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…