简体   繁体   English

运行.py文件时,“连续行字符后出现意外字符”?

[英]“Unexpected character after line continuation character” when running .py file?

I'm brand new to Python, so excuse my ignorance. 我是Python的新手,请原谅我的无知。 I also checked the other questions with this same error, but they all regarded the escape sequence "\\n". 我还检查了其他相同错误的问题,但他们都将转义序列视为“ \\ n”。 When attempting to run a python file from my Documents in the Python command line, I get the error "unexpected character after line continuation character." 尝试在Python命令行中从“文档”运行python文件时,出现错误“连续行字符后出现意外字符”。

I've tried reading straight from W3Schools , which says to use... 我尝试直接从W3Schools阅读,该书说使用...

C:\\Users\\Your Name>python helloworld.py

Since my file is in Documents in a file called test , I tried... 由于我的文件在一个名为test的文件中的文档中,因此我尝试了...

C:\\Users\\Chris\\Documents\\Python>python test.py

However, I received the given error. 但是,我收到了给定的错误。 Any help would be appreciated, thanks. 任何帮助,将不胜感激,谢谢。

Edit 编辑

In the OS command prompt, the py prefix should have been used, rather than python 在OS命令提示符中,应该使用py前缀,而不是python

Type python test.py into the shell directly, not into the python interpreter. 直接在外壳中输入python test.py ,而不是python解释器。 The C:\\Users\\Chris\\Documents\\Python> has backslashes in it, which cause this error as they make python expect the line to end. C:\\Users\\Chris\\Documents\\Python>包含反斜线,这会导致此错误,因为它们使python期望该行结束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM