About import

How to import python. The sample is a download using ** urllib.request **.

Pattern 1-1

sample.py


import urllib.request

#Specify the acquisition source URL and save file
url = "http://xxxx.xxx.xx/xx/xxx"
filename = "xxxxxx"

#download
urllib.request.urlretrieve(url, filename)

Pattern 1-2

sample.py


import urllib.request as hoge

#Specify the acquisition source URL and save file
url = "http://xxxx.xxx.xx/xx/xxx"
filename = "xxxxxx"

#download
hoge.urlretrieve(url, filename)

Pattern 2-1

sample.py


from urllib import request

#Specify the acquisition source URL and save file
url = "http://xxxx.xxx.xx/xx/xxx"
filename = "xxxxxx"

#download
request.urlretrieve(url, filename)

Pattern 2-2

sample.py


from urllib import request as hoge

#Specify the acquisition source URL and save file
url = "http://xxxx.xxx.xx/xx/xxx"
filename = "xxxxxx"

#download
hoge.urlretrieve(url, filename)

Recommended Posts

About import
About import
About LangID
About CAGR
About virtiofs
About python-apt
About Permission
About sklearn.preprocessing.Imputer
About gunicorn
About requirements.txt
About locale
About permissions
About axis = 0, axis = 1
About Opencv ③
About Python, from and import, as
About numpy
About pip
About Linux
Think about plug-in system-like things-dynamic import-
About numpy.newaxis
About endian
About Linux
About import error of PyQt5.QtWidgets (Anaconda)
About Opencv ①
About Linux
About Linux
About Linux ①
About cv2.imread
About _ and __
About wxPython
Notepad about TecoGAN
About python slices
Briefly about __name__
About python comprehension
About Docker Volume
[Linux] About export
About reference type
About Twitter scraping
About the test
2. Make import easier
Learn about programming
About Flask customization
Python module import
About variable scope. .. ..
About Python tqdm.
Notes about with
About python, class
About Linear Models
About Go functions
About pandas describe
Import python script
About Kivy root
scikit-learn import error
About Firestore timeout
About python inheritance
About python, range ()
About Confusion Matrix
[Linux] About PATH
About python decorators
Cannot import name'NUMPY_MKL'Solution.
Linux (about groups)