👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
I am trying to learn python and am making a program that will output a script. I want to use os.path.join, but am pretty confused. According to the docs if I say:
os.path.join("c:", "sourcedir")
I get "C:sourcedir"
. According to the docs, this is normal, right?
But when I use the copytree command, Python will output it the desired way, for example:
import shutil
src = os.path.join("c:", "src")
dst = os.path.join("c:", "dst")
shutil.copytree(src, dst)
Here is the error code I get:
WindowsError: [Error 3] The system cannot find the path specified: "C:src/*.*"
If I wrap the os.path.join
with os.path.normpath
I get the same error.
If this os.path.join
can"t be used this way, then I am confused as to its purpose.
According to the pages suggested by Stack Overflow, slashes should not be used in join—that is correct, I assume?
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from Python os.path.join on Windows, check other code Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano Python os.path.join on Windows
- Deutsch Python os.path.join on Windows
- Français Python os.path.join on Windows
- Español Python os.path.join on Windows
- Türk Python os.path.join on Windows
- Русский Python os.path.join on Windows
- Português Python os.path.join on Windows
- Polski Python os.path.join on Windows
- Nederlandse Python os.path.join on Windows
- 中文 Python os.path.join on Windows
- 한국어 Python os.path.join on Windows
- 日本語 Python os.path.join on Windows
- हिन्दी Python os.path.join on Windows
Paris | 2023-03-29
I was preparing for my coding interview, thanks for clarifying this - Python os.path.join on Windows in Python is not the simplest one. Checked yesterday, it works!
New York | 2023-03-29
Thanks for explaining! I was stuck with Python os.path.join on Windows for some hours, finally got it done 🤗. I am just not quite sure it is the best method
New York | 2023-03-29
Maybe there are another answers? What Python os.path.join on Windows exactly means?. Will get back tomorrow with feedback