Use pathlib instead of os.path in Python

If you are still worried about operating file paths and do not know how to use the os.path module, then it is time to try pathlib. pathlib library The pathlib library started with python3.4 and has become more mature by python3.6. If your new project can directly use 3.6 or above, it is recommended to […]

SolvingException “unhandled TypeError“ expected str, bytes or os.PathLike object, not tuple

Table of Contents SolvingException “unhandled TypeError” expected str, bytes or os.PathLike object, not tuple root cause of error Solution 1. Check the documentation for the function or method 2. Use indexed or unpacked parameters 3. Check whether the parameter values are correct 4. Check the implementation of the function or method Example Summarize Sample code: […]

Python file path puzzle: in-depth analysis of the essence of the os.path series of functions

Introduction In Python, the os.path module provides a set of functions for working with file paths and filesystems. It is part of the os module in the Python standard library. This article will discuss in depth how to use the os.path series of functions, from entry to mastery. Table of Contents Import the os.path module […]

Still using os.path? Pathlib in Python is too fragrant

Station B|Official account: a graduate student who knows everything Write in front I believe that many people are still accustomed to using os to handle files/folders/paths, etc., but in fact, the Pathlib library that comes with Python handles these more elegantly and safely. You will find that many large open source projects are using it, […]

Getting Started with PythonReading and writing of binary files, common attributes and methods of file objects, operation at any position of the file, serialization using pickle, operation of CSV files, os and os.path modules, os module-file and directory operations (twenty)

About the author: Hello everyone, I am Xiao Wang who loves to code, CSDN blogger, Python Xiaobai Series of columns: Python entry to actual combat, Python crawler development, Python office automation, Python data analysis, Python front-end and back-end development If there are any mistakes in the knowledge points of the article, please correct me! Learn […]

Python Insider Demystification: Deep analysis of os.path.join() under Windows system

Article directory refer to describe os.path path separator os.path.join() different implementation os.path.join() on Windows os.path.join() and ntpath.join() ntpath. join() Preparation os. fspath() isinstance() Iterable objects can only be tuples TypeError that may be raised nested tuples os.path.splitdrive() UNC path Components of a UNC path os.path.splitdrive() genericpath._check_arg_types() genericpath module genericpath._check_arg_types() Source code analysis of ntpath.join() function […]

Python Insider Demystified: Deep Analysis of os.path.join() in Unix-like Systems

Article directory refer to describe os.path path separator os.path.join() different implementation os.path.join() on Unix-like os.path.join() and posixpath.join() posixpath. join() Preparation os. fspath() posixpath._get_sep() map() startswitch() method and endswitch() method startswitch() endswitch() genericpath._check_arg_types() genericpath module genericpath._check_arg_types() Source code analysis of posixpath.join() function Concrete implementation of posixpath.join() (with notes) strange judgment statement path[:0] + sep Reference Project […]

[Solved] TypeError: expected str, bytes or os.PathLike object, not int when pip installs the library

TypeError: expected str, bytes or os.PathLike object, not int when pip installs the library View pip version number pip install –upgrade pip –no-cache-dir View pip version number When creating a new virtual environment on anaconda on the Ubuntu side, it is not clear what the problem is. After the new environment is created, the following […]