Open text file either locally or remotely via url with python -


I am working on a project where I need to read and read text files on a local server or remotely Url). Is there a Python function that works like php:

  file_get_contents ()   

Can you do this? I have now:

  def get_data_from_file (path): for i, line in enumerate (open): .....   

I want to pass in a local or remote way in some way.

You can try:

  def file_get_contents (path) : Try: excluding urllib.urlretrieve (path, file name = path): Print 'no one page' if os.path.exists (path): Open (Path, R) with file as: data = file. read () print data other: print 'no such file'    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -