用python檔案實現自動下載連結中的資源
阿新 • • 發佈:2019-01-14
import os
from subprocess import call
print("")
print("Downloading...")
if not os.path.exists("UCI HAR Dataset.zip"):
call(
'wget "https://archive.ics.uci.edu/ml/machine-learning-databases/00240/UCI HAR Dataset.zip"',
shell=True
)
print("Downloading done.\n")
else:
print("Dataset already downloaded. Did not download twice.\n")
print("Extracting...")
extract_directory = os.path.abspath("UCI HAR Dataset")
if not os.path.exists(extract_directory):
call(
'unzip -nq "UCI HAR Dataset.zip"',
shell=True
)
print("Extracting successfully done to {}.".format(extract_directory))
else:
print("Dataset already extracted. Did not extract twice.\n")