SyntaxError: Non-ASCII character

This is the place for queries that don't fit in any of the other categories.

SyntaxError: Non-ASCII character

Postby Ashkan » Wed Jun 12, 2013 7:01 pm

Hello everybody,

I'm a new user of Python and I have Python 2.7 on my windows laptop.
I just started to learn it and tried to right a one line program (for printing a name) and I got stuck. here is my code
Code: Select all
print "hi"

I got this error:
SyntaxError: Non-ASCII character '\xff' in file a.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
I tried to add these to the first line but still I got the same problem:
# -*- coding: utf-8 -*-

I'm using notepadd++ as an editor.

It would be the most kind of you to help me with this case.
I'm impatiently waiting to hear from you.
Last edited by Yoriz on Wed Jun 12, 2013 10:48 pm, edited 1 time in total.
Reason: Editted the title to include more information.
Ashkan
 
Posts: 4
Joined: Tue Jun 11, 2013 10:45 pm

Re: Syntax Error

Postby PurityLake » Wed Jun 12, 2013 7:28 pm

Send me the file
PurityLake
 
Posts: 7
Joined: Wed Jun 12, 2013 5:26 pm

Re: Syntax Error

Postby hansn » Wed Jun 12, 2013 8:23 pm

Did you try to use a new notepad++ file?
Or try to use another word processor, maybe the problem is with notepad++ ?
hansn
 
Posts: 87
Joined: Thu Feb 21, 2013 8:46 pm

Re: Syntax Error

Postby Ashkan » Wed Jun 12, 2013 8:53 pm

Dear PurityLake,
I couldn't upload the file to send you. Please lte me have your EMail address to do that.
By the way my EMail address is ashkan.khalili@gmail.com
Ashkan
 
Posts: 4
Joined: Tue Jun 11, 2013 10:45 pm

Re: Syntax Error

Postby Ashkan » Wed Jun 12, 2013 8:55 pm

Dear hansn,

I'm using new Notepad++
I have no idea about which kind of word processor I can use with it. Please let me know.

Regards,
Ashkan
 
Posts: 4
Joined: Tue Jun 11, 2013 10:45 pm

Re: Syntax Error

Postby hansn » Wed Jun 12, 2013 10:19 pm

I mean a new file, maybe the file you are currently editing is corrupted somehow. It has happened to me before.

You can use whatever word processor you like. Just try with a regular text document. As long as it is saved with a .py extension it is a python script :)
hansn
 
Posts: 87
Joined: Thu Feb 21, 2013 8:46 pm

Re: Syntax Error

Postby Ashkan » Wed Jun 12, 2013 10:41 pm

Hansn,
You were right. Now it's working. :D
Thanks so much.
Regards,
Ashkan
 
Posts: 4
Joined: Tue Jun 11, 2013 10:45 pm

Re: SyntaxError: Non-ASCII character

Postby micseydel » Thu Jun 13, 2013 12:13 am

I deleted the post you made in someone else's thread. If you have a question and have found a related thread, create your own and link to the old one, don't hijack someone else's code.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 941
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 1 guest