Skip to main content

XNBConfig

By This is XiaoDeng

介绍

XNBConfig 提供了一个类似于 易语言配置项相关操作 的Python3读写json的新姿势,同时还提供了自己的读写函数;可以用较短的代码实现 json 创建、读写,让代码更整洁!

编译步骤

GIT(最新)

  1. 克隆仓库
  2. 将XNBConfig移动到项目文件夹内
  3. 导入:
import XNBConfig as conf

PIP(最快)

  1. pip install xnbconfig
  2. 导入:
import XNBConfig as conf

函数列表

因为懒得打,XNBConfig简称conf

conf.read(file,key,default = "",encode = "utf-8") => int/str/False(失败)

  • 参数:
    • file:文件名 -str
    • key:读取键的名称 -str
    • default:默认值(当key不存在时,赋值值于此)
    • encode:编码 -str
  • 作用:读取某json文件的指定键的值
  • 返回:该json内key值

conf.write(file,key,value,encode="utf-8") => True/False(失败)

  • 参数:
    • file:文件名 -str
    • key:写入键的名称 -str
    • value:值
    • encode:编码 -str
  • 作用:创建/写入指定json文件的键值
  • 返回:布尔值:操作结果(成功/失败)

conf.openjson(file,encoding="utf-8")

  • 参数:
    • file:文件名
    • encoding:文件编码
  • 作用:打开一个文件
  • 返回:<class 'XNBConfig.openjson'>

<class 'XNBConfig.openjson'>.readall(json = True) => str/json

  • 参数:
    • json:返回json格式
  • 作用:读取整个文件
  • 返回:
    • json=True:字典
    • json=False:字符串

<class 'XNBConfig.openjson'>.add(key,value)

  • 参数:
    • key:键
    • value:值
  • 作用:写入键值到json
  • 返回:更改后的值

<class 'XNBConfig.openjson'>.getvalue(key,value = "")

  • 参数:
    • key:同conf.read(key)
    • value:默认值
  • 作用:读取值
  • 返回:值

贡献名单

程序

这里是小邓

README.md修正

StarWorld

起名

FZZkill

TODO

  • [] 更灵活的json格式
  • [] 中文函数(待定)

Metadata

Release files for XNBConfig 1.0

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

Source distribution (sdist)

Source distribution for XNBConfig 1.0
File Size Uploaded
XNBConfig-1.0.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for XNBConfig 1.0
File Interpreter ABI Platform
XNBConfig-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.9 kB

Release files / XNBConfig-1.0.tar.gz

Download URL XNBConfig-1.0.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b23b6a6c4f09a6501d17cf66017729bdaf5ea12fb0f4bdedf1b343205fdaf7bb
BLAKE2b-256 checksum
How to use checksums
187dbc53fbd9705d1db0a6df21d30eaa4cade4217dc32a1d27c7bd949ca789ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release files / XNBConfig-1.0-py3-none-any.whl

Download URL XNBConfig-1.0-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99d45aa76c0a54de98b5b966a51649e0f66e6f83cb19a25479024be27c486826
BLAKE2b-256 checksum
How to use checksums
ae3d0b57833573694ff907cf92faf51d2a83dd82a0afa1fb5cc8d29f5cfaea38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

0.0.0

1 release file

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