IOError:[Erno 22]url的参数无效



我是python新手,正在尝试用写模式打开本地主机但我得到了以下错误

with io.open('http:\localhost:3000\assets\i18n\locale-ru.json', 'w') as outfile:

IOError: [Errno 22] Invalid argument: 'http:\localhost:3000\assets\i18n\locale-ru.json'

这里有一段代码:

 with io.open('http://localhost:3000//assets//i18n//locale-ru.json', 'w') as outfile:
  str_ = json.dumps(data_ru,
                    indent=4, sort_keys=True,
                    separators=(',', ': '), ensure_ascii=False)
  outfile.write(to_unicode(str_))

根据文档,io.open函数只读取给定文件路径的本地文件。考虑到你正在尝试从http url中读取,我想更好的工具可能是请求

最新更新