readlines from file python code example
Example 1: how to download file from python
import wget
url = "https://www.python.org/static/img/[email protected]"
wget.download(url, 'c:/users/LikeGeeks/downloads/pythonLogo.png')
Example 2: python writeline file
f = open("test.txt", "w")
f.writelines(["Hello", "World"])
f.close
Example 3: python writeline file
f = open("test.txt", "w")
f.write("Hello \nWorld")
f.close
Example 4: python read lines
f = open("filename")
lines = f.readlines()
Example 5: readlines from file python
f = open("file.txt", 'r')
print(f.readlines()) # array of file lines
Example 6: how to download file in python
import urllib.request
print('Beginning file download with urllib2...')
url = 'http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg'
urllib.request.urlretrieve(url, '/Users/scott/Downloads/cat.jpg')