Safe open function
Project description
Introduction
How to use
from safe_open 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.2.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.2.tar.gz.
File metadata
- Download URL: safe_open-0.2.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 |
09018e73aa75409bdf877f4a2211056c153fa62b861d876344e41df1b62f54e1
|
|
| MD5 |
8fb47eef4b9a489b5f2885994140a78e
|
|
| BLAKE2b-256 |
6760941943f636d72e8286087777dde47eafacb4c44d9ab2e7921d5aec0d7884
|
File details
Details for the file safe_open-0.2-py3-none-any.whl.
File metadata
- Download URL: safe_open-0.2-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 |
3033f4bc28e6551c03a358eb87d1e217fbc843ec20174a4f66fe8989f01ab1cf
|
|
| MD5 |
ed286c9f8fb8d53f92d386d62d9df787
|
|
| BLAKE2b-256 |
273b2418f018f18db894cce38413305571c4e97c1e912f885a0cef9f192cbca8
|