Python Forum
SyntaxError: EOL while scanning string literal on with open() statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyntaxError: EOL while scanning string literal on with open() statement
#1
Hi! I am getting this error message in Python 3.6.3, using Spyder 3.2 in Anaconda 5.0.1 on Windows 7.
^
SyntaxError: EOL while scanning string literal
The interpreter is pointing to the colon at the end of the first line...

with open ("hello.txt', 'w') as f:
    f.write('writing over hello world')
This docs page says in section 7.2 that is how it's supposed to be written in Python 3. Python 3 Documentation

What is wrong with the code here? Huh Thank you..
Reply
#2
you open with " but never close it
with open ("hello.txt', 'w') as f:
should be:
with open ("hello.txt", 'w') as f:
Reply
#3
Ah, thank you! Just needed to increase the font size in Spyder with Ctrl+.
Reply
#4
No, you just needed to close the string you started. :P
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 6,672 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  Trying to compare string values in an if statement israelsattleen 1 541 Jul-08-2023, 03:49 PM
Last Post: deanhystad
  String concatenation in SQL update statement hammer 3 1,504 Feb-24-2022, 08:00 PM
Last Post: hammer
  trying to understand a string literal in a basic server program CompleteNewb 4 2,105 Nov-14-2021, 05:33 AM
Last Post: deanhystad
  if statement string match javiopro 2 1,634 Sep-04-2021, 05:56 PM
Last Post: javiopro
  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,428 Apr-29-2020, 05:48 AM
Last Post: markfilan
  SyntaxError: multiple statements found while compiling a single statement Kayode_Odeyinka 1 2,980 Mar-12-2020, 05:50 PM
Last Post: micseydel
  How To Find an Opening and Closing String, Copying Open/Close/Contents to New File davidshq 1 2,029 Mar-03-2020, 04:47 AM
Last Post: davidshq
  open, read and replace a string in a file Reims 0 1,804 Oct-02-2019, 01:30 PM
Last Post: Reims

Forum Jump:

User Panel Messages

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