The code below calls upon a Python script to generate pinyin from Chinese characters in region:
(defun pinyin () "Generate Pinyin from Chinese Characters with Python script, keeping the original Chinese characters intact." (interactive) (let ((cmdStr (format "python3 -c \"import pinyin; print(pinyin.get(\'%s\', delimiter=\' \'))\"" (buffer-substring (region-beginning) (region-end))))) (insert (format "\n%s" (shell-command cmdStr (buffer-file-name))))))
I would like the script to insert the pinyin on a new line under the selected Chinese characters.
The above script correctly displays the desired output in the mini-buffer but inserts
0 at the place where the pinyin should be.
What went wrong and how can I get this working properly?