Safe open function
Project description
Introduction
How to use
import safe_open
with safe_open("test.txt", "w") as f:
f.write("Hello, World!") # 正常写入
with safe_open("test.txt", "r") as f:
content = f.read() # 正常读取
with safe_open("test.txt", "w") as f: # OSError: file mode error: cannot read in write mode
content = f.read() # 异常读取
with safe_open("test.txt", "r") as f: # OSError: file mode error: cannot write in read mode
content = f.write() # 异常写入
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
safe_open-0.1.tar.gz
(2.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file safe_open-0.1.tar.gz.
File metadata
- Download URL: safe_open-0.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
335c755055a3efa7c96f882210ce57c2cd391072e14879886b7fcc191a2ee995
|
|
| MD5 |
8594be19121dbb906a14e0ae43a70d02
|
|
| BLAKE2b-256 |
83751ba555b42227d5862b5d1b0aaaf249ea947c0fb8b3dbd743931a240672dc
|
File details
Details for the file safe_open-0.1-py3-none-any.whl.
File metadata
- Download URL: safe_open-0.1-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5596e14f4c303d9000747a790265b203604670cf565ada2afc3bdd53d7e5d240
|
|
| MD5 |
fe0fd6bd0d08b50249bdaffcb4700e0d
|
|
| BLAKE2b-256 |
5b5198e59dfcde7681799f4ab63beb0461eb823b23580d42b4af06fd6eeb97a8
|