问题
Calling LibreOffice to convert a document to text...
This works fine from the linux command line:
soffice --headless --convert-to txt:"Text" document_to_convert.doc
But I get an error when I try to run the same command from Python:
subprocess.call(['soffice', '--headless', '--convert-to', 'txt:"Text"', 'document_to_convert.doc'])
Error: Please reverify input parameters...
How do I get the command to run from Python?
回答1:
This is the code you should use:
subprocess.call(['soffice', '--headless', '--convert-to', 'txt:Text', 'document_to_convert.doc'])
This is the same line you posted, without the quotes around txt:Text
.
Why are you seeing the error? Simply put: because soffice does not accept txt:"Text"
. It only accepts txt:Text
.
Why is it working on the shell? Your shell implicitly removes quotes around arguments, so that the command that gets executed is actually:
soffice --headless --convert-to txt:Text document_to_convert.doc
Try running this command:
soffice --headless --convert-to txt:\"Text\" document_to_convert.doc
Quotes won't be removed and you'll see the Please verify input parameters message you are getting with Python.
来源:https://stackoverflow.com/questions/30125574/error-calling-libreoffice-from-python