Basic Python Hello World Program Syntax Error

扶醉桌前 提交于 2019-11-28 14:14:32
Jakub Hampl

Check to make sure that you are really using straight quotes. Some programs/systems automatically replace them with curly quotes.

Here try copy pasting this and running it:

print "hello"

If this turn's out to be an issue then you might want to ask at https://unix.stackexchange.com/ how to disable such a feature.

It looks like you're typing different double-quotes than what Python requires. Maybe your IME has "smart quotes" turned on or something? Anyway, you could try:

print 'hello world'

using single quotes (really, the apostrophe character) as an alternative. If you can't make that work, then copy and paste what I've written in this answer and that should work.

Here's one with double quotes for you to copy too:

print "hello world"

You need to use single (') or double (") quotes, not fancy quotes or diaereses as you did.

print "Hello, World!" 

IF you have copy-pasted the code from a CHM / PDF file then be aware of the quotes. What appears as single / double quotes in the pdf is not treated as quotes in the text editor/shell etc.

type out the code on the py shell. it should work!

The problem here is with the double quotes. Try to use a different word editor , it will surely solve the problem. For Linux , install gedit and then type the code and run it. For Mac, Install Text Wrangler and For Windows , Install Notepad++.

This will definitely solve your problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!