Search

EOL while scanning string literal

The following error might come in python when working with strings that have a "\" in it.



This error is generally because of the use of the backslash in a string operation. For example , consider the string



If we want to split the string using "\" as the seperator, we can not use



The above split command will throw the EOL error. To get around this, we need the escape the special meaning of the "\" by using another "\" preceding it.



Using split function by prefixing a "\" with another "\" will ensure that we do not get the EOL error

No comments:

Post a Comment