Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String with EOF in python [duplicate]

Tags:

python

string

eof

how can I store in a variable, a string containing the EOF character? In other words, how can I represent EOF in a python string?

Thanks in advance

like image 944
Throoze Avatar asked Mar 07 '15 09:03

Throoze


People also ask

How do I fix EOF error in Python?

How EOFError can be overcome? We overcome this problem by using keywords like try() and except() in Python. This is referred to as Exception Handling.

Is EOF and \n same?

A return value of EOF from fgetc() and friends can occur at any time - even in the middle of a line due to an error. Otherwise, no: A end-of-file does not occur at the end of a line with a '\n' . Typically the last line in a file that contains at least 1 character (and no `'\n') will also be a line.

How do you write EOF in Python?

Python doesn't have built-in eof detection function but that functionality is available in two ways: f. read(1) will return b'' if there are no more bytes to read. This works for text as well as binary files. The second way is to use f.

What is EOF error in Python?

EOF stands for End of File in Python. Unexpected EOF implies that the interpreter has reached the end of our program before executing all the code. This error is likely to occur when: we fail to declare a statement for loop ( while / for ) we omit the closing parenthesis or curly bracket in a block of code.


1 Answers

There is no EOF character.... Usually it is just when you run out of data. If you really want one, you could just make some arbitrary string combination up, but you are probably better off just reading each line until the file is out of data.

like image 73
John Avatar answered Nov 03 '22 02:11

John