Python Forum
SyntaxError: EOL while scanning string literal
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyntaxError: EOL while scanning string literal
#1
Hey Guys,

Im trying in look in the registry for an item based off what the user inputs. For some reason the last back slash is causing issues. I need this to look for the next entry, but how do I go forward with it?

usr_input = raw_input('What Program would you like to search for? ')
location = 'SYSTEM\ControlSet001\services\'
RegLocation = location + usr_input
Reply
#2
Please show enough code so that it can be run as supplied
and Please show full traceback messages (all of them, verbatim)
Reply
#3
import _winreg
from _winreg import *
usr_input = raw_input('What Program would you like to search for? ')
location = 'SYSTEM\ControlSet001\services\'
RegLocation = location + usr_input
def getMDACversion():
    hKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, RegLocation)
    result = _winreg.QueryValueEx(hKey, "ImagePath")
    return result[0]
print getMDACversion()
Reply
#4
try:

location=r'SYSTEM\ControlSet001\services\'
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
No luck same thing.

If it matters im using code 2.7
Reply
#6
That shouldn't matter. What is the full traceback?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#7
Full Traceback? Im sorry I don't understand.
Reply
#8
The Traceback is the error code.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#9
location = r'SYSTEM\ControlSet001\services\'
^
SyntaxError: EOL while scanning string literal





The arrow is pointing to the ' mark instead of the beginning.

The backslash at the end and comma are also blue in Atom.
Reply
#10
You're right the raw string (r'...') doesn't work right. Double all of the backslashes in the string and take away the r and it should work.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 6,673 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  trying to understand a string literal in a basic server program CompleteNewb 4 2,105 Nov-14-2021, 05:33 AM
Last Post: deanhystad
  EOF while scanning triple-quoted string literal louis216 1 3,932 Jun-30-2020, 04:11 AM
Last Post: bowlofred
  invalid literal for int() with base 10: '' mrsenorchuck 5 5,430 Apr-29-2020, 05:48 AM
Last Post: markfilan
  Syntax Error EOL while scanning string literal intjuma 0 2,484 Jun-28-2019, 01:56 AM
Last Post: intjuma
  SyntaxError: EOL while scanning string literal on with open() statement Regulus 3 7,343 Feb-23-2018, 06:40 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020