Para usar str.join .
Source code: Lib/posixpath.py (for POSIX),
Lib/ntpath.py (for Windows NT),
and Lib/macpath.py (for Macintosh)
Web Archive : https://web.archive.org/web/20190915150401/https://docs.python.org/3/library/os.path.html
Web Archive : https://web.archive.org/web/20190915150747/https://docs.python.org/3/library/stdtypes.html?highlight=str%20replace
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 driveC:
(c:foo
), notc:\foo
.
Changed in version 3.6: Accepts a path-like object for path and paths.
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.
Web Archive : https://web.archive.org/web/20190915150747/https://docs.python.org/3/library/stdtypes.html?highlight=str%20replace
Comentários
Postar um comentário