【问题标题】:Python 3, parsing jsonPython 3,解析 json
【发布时间】:2013-07-06 09:06:03
【问题描述】:

请帮忙,我遇到了这个错误:

with open('Data/language.json') as settings_file:
TypeError: Required argument 'flags' (pos 2) not found

我的代码是:

import json

with open('Data/settings.json') as settings_file:    
    Settings = json.load(settings_file)

【问题讨论】:

  • 你碰巧做了from os import open吗? open(不需要导入的内置open)自动默认为读取模式。
  • 是的,我做到了,我删除了它,现在可以使用了,谢谢 :)
  • @Blender:让它成为一个答案。

标签: python json python-3.x


【解决方案1】:

看起来您从os 模块导入了open,内容如下:

from os import open

os.open 与内置的 open 函数不同(您不需要导入)。删除该导入,您将使用内置的open,默认为读取模式。

【讨论】:

    猜你喜欢
    • 2023-04-10
    • 2016-05-09
    • 1970-01-01
    • 1970-01-01
    • 2012-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多