Skip to main content

处理windows路径

直接复制windows路径中,字符串中包含反斜杠,一般需要改成双反斜杠或者rstr。 用slash_path,可以直接用反斜杠的windows路径,产生Path对象,更方便一些。

参考项目

主要代码参考了这个最后一个:https://discourse.techart.online/t/python-handling-windows-path-with-characters/12045/18。

安装

$ pip install slash_path

使用

from slash_path import SlashPath
path_str = 'D:\next_cloud\newfile.txt'
sp = SlashPath(path_str)

更多范例参见utest文件夹。

Metadata

Release files for slash-path 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slash-path 0.1.1
File Size Uploaded Provenance Actions
slash_path-0.1.1.tar.gz 3.1 kB Without provenance Details for slash_path-0.1.1.tar.gz

Release files / slash_path-0.1.1.tar.gz

Download URL slash_path-0.1.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d69c4fb0b35af9978b367191e08479fca9245786fcd35ac373758ebf081373f4
BLAKE2b-256 checksum
How to use checksums
0cab45d038c379ac6ed3dd08e8c7235f4353e21e7907539fff7f55da687a14ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.10

Security for slash-path 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page