There is a read-only library that takes a file as an argument. But I have a line.
How to convert a string to a file so that, after reading the file, it will return this string? I do not want to write to disk.
Module StringIO:
StringIO
>>> import StringIO >>> f = StringIO.StringIO("foo") >>> f.read() 'foo'
The module cStringIOhas the same interface and is faster, but cannot process Unicode strings that have non-ASCII characters.
cStringIO
StringIO Documentation
what you need? if you want to read from a file just use:
file('/path/to/file').read()
or
open('/path/to/file','r').read()
if you want to read a line, just do as Phil suggested
Source: https://habr.com/ru/post/1720145/More articles:Комплект тестирования для реализации Linked List? (и/или других структур данных) - javacreating a cross-platform zip file - rneed help understanding this erlang code - erlangWhy wait for asynchronous web service calls - c #Google OAuth with Indy in Delphi - oauthLisp: как написать функцию более высокого порядка - lispOCaml - for a loop inside an If statement - for-loopHow to capture ping return value in C ++ - c ++Why is my dll not registering? - c ++checking for text field (no spaces) - asp.netAll Articles