It seems to be os.sep returns "/" as a separator, I wonder if I can use that to make a URL:
eg. To get a url like https://some.domain.com/catalogs
protocol + request.get_host() + os.sep + get_file_name()
I recommend you use os.path.sep for anycodings_python clarity, since it's a path separator, anycodings_python not an OS separator. If you import anycodings_python os.path as path you can call it anycodings_python path.sep, which is even better.,The character used by the operating anycodings_python system to separate pathname components. anycodings_python This is '/' for POSIX and '\' for anycodings_python Windows.,I'd use os.path.sep to make it very anycodings_python clear that it's the path anycodings_python separator… But consistency is anycodings_python more important, so if one is already anycodings_python being used, use that. Otherwise, pick anycodings_python one and use it all the time.,I guess the os.path.sep.join is more anycodings_python robust and can be used w/o modifications anycodings_python for any os.
Edit: Just to make sure you're not anycodings_python reinventing the wheel, though, the path anycodings_python module already has join, split, dirname, anycodings_python and basename functions… So anycodings_python you should rarely need to use path.sep:
>>> os.path.join("foo", "bar", "baz")
'foo/bar/baz' >>>
os.path.split(_)
('foo/bar', 'baz')
The following examples could highlight anycodings_python the differences between os.path.join and anycodings_python os.path.sep.join.
>>>
import os
>>>
os.path.join("output", "images", "saved")
'output/images/saved' >>>
os.path.sep.join(["output", "images", "saved"])
'output/images/saved'
Both of them belongs to the same python anycodings_python class also.
print(type(os.sep))
print(type(os.path.sep))
# Output
<class 'str'>
<class 'str'>
Both have them have the same anycodings_python documentation.
print(os.path.sep.__doc__) print(os.sep.__doc__) # The outputs of both print statements are the same.
Updated: November 12, 2020
# Import necessary packages
import os
from glob
import glob
import earthpy as et
# Download data on average monthly temp for two California sites file_url = "https://ndownloader.figshare.com/files/21894528" et.data.get_data(url = file_url)
Downloading from https: //ndownloader.figshare.com/files/21894528
Extracted output to / root / earth - analytics / data / earthpy - downloads / avg - monthly - temp - fahr
'/root/earth-analytics/data/earthpy-downloads/avg-monthly-temp-fahr'
# Set working directory to earth - analytics os.chdir(os.path.join(et.io.HOME, "earth-analytics")) # Create a path to the data folder data_folder = os.path.join("data", "earthpy-downloads", "avg-monthly-temp-fahr")
# Get a specific directory file_list = glob(data_folder) file_list