Python Forum
unexpected character after line continuation character error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unexpected character after line continuation character error
#1
hi
im learning python for about 5 minutes now and trying to run python from a windows terminal(giving the directory to the termminal so the terminal finds and run it) and im having this error:
SyntaxError: unexpected character after line continuation character.
my code is:
C:\> cd Desktop\Python
and its the same as the example in the book(Python Crash Course) but i have no clue what is wrong.
any idea what is this for?
OS: Windows 10
Python V 3.7.0
Reply
#2
this is not code, it's a OS command to change directory
C:\> cd Desktop\Python
from command line, if you want interactive python, simply type:
python
if you want to run a python script, for example myscript.py, use:
python myscript.py
Reply
#3
That's not Python. That's the Windows command to change directories. You would type that at the Windows command line to get to the Python folder on your desktop.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#4
(Aug-01-2018, 09:07 PM)Larz60+ Wrote: this is not code, it's a OS command to change directory
C:\> cd Desktop\Python
from command line, if you want interactive python, simply type:
python
if you want to run a python script, for example myscript.py, use:
python myscript.py

lol, thx but got nothing out of it yet.
error is (in the os command window):'C:\' is not recognized as an internal or external command,
operable program or batch file.
tried this with all three ways u said and still nothing.
checked the directory and it was not wrong.
Reply
#5
drop c:\
type what I show verbatim
Reply
#6
(Aug-05-2018, 08:47 PM)Larz60+ Wrote: drop c:\
type what I show verbatim

still nothing, just an "invalid syntax" error.
copied ur lines and changed my folder names to them exactly.
thx tho, maybe i can find the way to do this on utube.
Reply
#7
please show everything on your screen, including prompts, etc.
There is something wrong here,
for example if you see >>>
show that and everything else.
Reply
#8
(Aug-06-2018, 07:55 PM)Larz60+ Wrote: please show everything on your screen, including prompts, etc.
There is something wrong here,
for example if you see >>>
show that and everything else.

this is what happens in command window:

C:\Users\admin\Desktop>C:\> cd Desktop\Python
'C:\' is not recognized as an internal or external command,
operable program or batch file.

it also makes a file named "cd" in my desktop and its empty.
Reply
#9
[python]cd stands for change directory.
Why are you trying to change director while trying to run python?
type the following verbatim from command line:
Output:
python
nothing more, nothing less. Got it???
Reply
#10
cmd tutorial
Python 3.6/3.7 and pip installation under Windows

A run in cmd:
Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. Med enerett.

# Change directory to root C:
C:\Windows\System32>cd\

# Test Python 
C:\>python -V
Python 3.7.0

# Test pip
C:\>pip -V
pip 18.0 from c:\python37\lib\site-packages\pip (python 3.7)

# Change directory to foo:
C:\>cd foo

# look at hello.py
C:\foo>more hello.py
print('hello world')

# Run hello.py
C:\foo>python hello.py
hello world

# Interactive interpreter
C:\foo>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 'foo'
>>> a * 5
'foofoofoofoofoo'
>>> exit()

C:\foo>
When i type command is only text marked in blue.
C:\Windows\System32>cd\
C:\foo>python hello.py
C:\foo>more hello.py
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using regex to count specific character in file shamishd 1 1,618 Oct-01-2021, 07:33 AM
Last Post: snippsat
  Split string into 160-character chunks while adding text to each part iambobbiekings 9 9,605 Jan-27-2021, 08:15 AM
Last Post: iambobbiekings
  Replacing a few characters of a specified character but not all of them from a string fatherted99 7 3,213 Aug-13-2020, 09:08 AM
Last Post: fatherted99
  Change each character of list into an different characters Angry_bird89 1 2,053 Jun-19-2020, 08:29 AM
Last Post: Angry_bird89
  Search character from 2d list to 2d list AHK2019 3 2,489 Sep-25-2019, 08:14 PM
Last Post: ichabod801
  Tab character in a string prints 8 spaces hecresper 6 20,575 Aug-27-2019, 02:38 PM
Last Post: snippsat
  Print strings enclosed with a character with different characters aylmaoxd 1 1,923 Aug-17-2019, 03:35 PM
Last Post: Resistance
  getting an error"Line 7: TypeError: 'int' object is not callable" JTNA 4 7,236 Apr-03-2019, 01:58 PM
Last Post: JTNA
  Finding and storing all string with character A at middle position Pippi 2 2,679 Jan-20-2019, 08:23 AM
Last Post: Pippi
  SSL Certificate Error when trying to do command-line registration with pypi DeliriousDelight 0 2,697 Dec-06-2018, 09:38 AM
Last Post: DeliriousDelight

Forum Jump:

User Panel Messages

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