ymal error-ScannerError:扫描双引号标量时



访问yaml文件时出错

配置yaml

input_path: "/home/jupyter/Redacted_Contracts/test_path/*/*.pdf"
output_path: "/home/jupyter/gcs/"

当我运行以下代码时

filename = 'config.yaml'
if __name__ == "__main__":

with open(filename) as f:
config = yaml.load(f, Loader=yaml.FullLoader)

获取以下错误消息

ScannerError: while scanning a double-quoted scalar
in "config.yaml", line 1, column 13
expected escape sequence of 8 hexadecimal numbers, but found 's'
in "config.yaml", line 1, column 18

我在数学模式中遇到了同样的问题——存储等参数名称

--- 
params:
- "$alpha$"
- "$beta$" 
...

如果你有类似的东西,试着用r字符串或上面建议的单引号。

编辑:打字错误和清除

不要在yaml文件中保留双引号

input_path: /home/jupyter/Redacted_Contracts/test_path/*/*.pdf
output_path: /home/jupyter/gcs/

这将启用值中的特殊字符检查。

最新更新