问题描述
我正在编写代码以使用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: Invalid escape: line 11 column 34 (char 461)
这是回溯:
D:solr640contribltrexample>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:UsersPankajAppDataLocalProgramsPythonPython36-32libjson\__init__.py", line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "C:UsersPankajAppDataLocalProgramsPythonPython36-32libjson\__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "C:UsersPankajAppDataLocalProgramsPythonPython36-32libjsondecoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:UsersPankajAppDataLocalProgramsPythonPython36-32libjsondecoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid escape: line 11 column 34 (char 461)
config.json 文件内容
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: Invalid escape的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!