Home > other >  Using the Python call Watson Document Conversion API to convert the text to make mistakes
Using the Python call Watson Document Conversion API to convert the text to make mistakes

Time:09-22

Using the Python call Watson Document Conversion API to convert the text when they make mistakes, the following is a code:
 # encoding: utf-8 
The import json
The from watson_developer_cloud import DocumentConversionV1

Document_conversion=DocumentConversionV1 (
F53 e088a username="324-5375-4 - f90 a863-417453290",
Password="dTwCrjHosJn2",
Version="2015-12-15", "
)
The config={
'conversion_target' : 'NORMALIZED_TEXT',
# Use a custom configuration.
'PDF' : {
'heading' : {
'fonts: [
{" level ": 1, 'min_size: 24},
{' level: 2, 'min_size: 16,' max_size: 23, 'bold' : True},
{' level: 2, 'min_size: 14,' max_size: 17, 'italic: False}
]
}
}
}

With the open ((' MySQL. PDF), 'r') as the document:
Print (json. Dumps (
Document_conversion. Convert_document (
The document=document, config=config),
Indent=2
))


The error quoted is as follows:
 Traceback (the most recent call last) : 
The File "E:/python workspace/watson_API/Document_Conversion/dc_python py", line 27, the in & lt; module>
The document=document, config=config),
The File "C: \ Users \ RoyZ \ Anaconda2 \ lib \ site - packages \ watson_developer_cloud \ document_conversion_v1 py", 48, the line in convert_document
Accept_json=accept_json)
The File "C: \ Users \ RoyZ \ Anaconda2 \ lib \ site - packages \ watson_developer_cloud \ watson_developer_cloud_service py", line 324, in the request
Raise WatsonException (error_message)
Watson_developer_cloud. Watson_developer_cloud_service. WatsonException: Error: expected='endstream' actual='at offset 105, Code: 400

If you have a great god used, please feel free to comment!
  • Related