Pular para o conteúdo principal

Melhorar os.path.join(path, *paths)

Para usar str.join .

os.path — Common pathname manipulations

Source code: Lib/posixpath.py (for POSIX), Lib/ntpath.py (for Windows NT), and Lib/macpath.py (for Macintosh)
os.path.join(path, *paths)
Join one or more path components intelligently. The return value is the concatenation of path and any members of *paths with exactly one directory separator (os.sep) following each non-empty part except the last, meaning that the result will only end in a separator if the last part is empty. If a component is an absolute path, all previous components are thrown away and joining continues from the absolute path component.
On Windows, the drive letter is not reset when an absolute path component (e.g., r'\foo') is encountered. If a component contains a drive letter, all previous components are thrown away and the drive letter is reset. Note that since there is a current directory for each drive, os.path.join("c:", "foo") represents a path relative to the current directory on drive C: (c:foo), not c:\foo.
Changed in version 3.6: Accepts a path-like object for path and paths.
Fonte : https://docs.python.org/3/library/os.path.html
Web Archive : https://web.archive.org/web/20190915150401/https://docs.python.org/3/library/os.path.html

str.replace(old, new[, count])
Return a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced.
Fonte : https://docs.python.org/3/library/stdtypes.html?highlight=str%20replace#str.replace
Web Archive : https://web.archive.org/web/20190915150747/https://docs.python.org/3/library/stdtypes.html?highlight=str%20replace




Comentários