Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含一些数据的文件,但它不是 JSON,我不知道如何使用 Python 或 Java 解析这种格式。
文件内容看起来像这样
id: 34 account :143456 macAddress: 00-10-FA-6E-38-4A
这是一个单行:
data = dict(line.split(": ", 1) for line in file)
展开:
data = {} for line in file: k, v = line.split(": ", 1) data[k] = v