Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
497 views
in Technique[技术] by (71.8m points)

zip - Python ZipFile path separators

If I am unzipping a Zip file with the Python ZipFile library, where the file was created on Windows, but my code is running on Unix-like, will the path separators always be Unix-style?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Internally, ZipFile stores forward slashes as required by the zip file specification.

Externally, they get translated using os.sep so it will match what is normally expected on a given platform.

Code references:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...