json读取错误json.decoder.JSONDecodeError:无效\ escape [英] json reading error json.decoder.JSONDecodeError: Invalid \escape

查看:1606
本文介绍了json读取错误json.decoder.JSONDecodeError:无效\ escape的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写代码,以使用"config.json"文件设置在solr中上载模型(train_and_upload_demo_model.py).但我遇到以下错误:

I am writing a code to upload a model (train_and_upload_demo_model.py) in solr using "config.json" file settings. but i am getting following error:

json.decoder.JSONDecodeError:无效\ escape:第11行第34列(字符461) 这是这里的回溯:

json.decoder.JSONDecodeError: Invalid \escape: line 11 column 34 (char 461) this is the traceback here:

D:\solr640\contrib\ltr\example>python train_and_upload_demo_model.py -c config.json

Traceback (most recent call last):
  File "train_and_upload_demo_model.py", line 182, in <module>
    sys.exit(main())
  File "train_and_upload_demo_model.py", line 158, in main
    config = json.load(configFile)
  File "C:\Users\Pankaj\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "C:\Users\Pankaj\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Pankaj\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Pankaj\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 11 column 34 (char 461)


content of config.json file

  {
    "host":                     "localhost",
    "port":                     8983,
    "collection":               "techproducts",
    "requestHandler":           "query",
    "q":                        "*:*",
    "efiParams":                "efi.user_query='$USERQUERY'",
    "userQueriesFile":          "user_queries.txt",
    "trainingFile":             "exampleTrainingFile.txt",
    "trainedModelFile":         "exampleTrainedModel.txt",
    "trainingLibraryLocation":  "D:\liblinear-2.11",
    "trainingLibraryOptions":   "-q",
    "solrFeaturesFile":         "exampleFeatures.json",
    "solrFeatureStoreName":     "exampleFeatureStore",
    "solrModelFile":            "exampleModel.json",
    "solrModelName":            "exampleModel"
  }

我可以知道我在哪里犯错吗?

can i get to know where i am making the mistake?

这是否是由于"trainingLibraryLocation"而导致的错误:"D:\ liblinear-2.11",语法?因为这是行号11

Is this is the error because of "trainingLibraryLocation": "D:\liblinear-2.11", syntax?? because this is the line no. 11

还有其他方法可以传递目录位置.

Is there any other way to pass directory location.

推荐答案

"trainingLibraryLocation": "D:\liblinear-2.11"中的\l被视为转义序列.尝试转义斜线本身,即. "D:\\liblinear-2.11".

The \l in "trainingLibraryLocation": "D:\liblinear-2.11" is treated like an escape sequence. Try escaping the slash itself, ie. "D:\\liblinear-2.11".

这篇关于json读取错误json.decoder.JSONDecodeError:无效\ escape的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆