Python+ubuntu error -


am trying run following python program

import re regex=re.compile("http...imgs.xkcd.com.comics.[\\s]*.[jpg|png]") f=open('out.txt') in f:     print regex.findall(a)     print '\n' 

when type code interpreter manually, works expected when save file , try run , gives errors. command used run is

chmod +x  sudo ./pymod.py 

error: ./pymod.py: 2: syntax error: "(" unexpected

if dont use sudo, error is

./pymod.py: line 2: syntax error near unexpected token `(' ./pymod.py: line 2: `regex=re.compile("http...imgs.xkcd.com.comics.[\\s]*.[jpg|png]")' 

am using ubuntu 10.04 on default

it takes 10-15 seconds error appear

when set executable, have specify want run with, or linux consider bash script.

add first line of file:

#!/usr/bin/python 

or run like:

python pymod.py 

cheers!


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -