Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

I attempted to utilize Python with the command line parser 'kakasi' together. Here is my code: 

# -*- coding: utf-8 -*-

import os

text = 'スッキリわかる Java入門 実践編 第2版'

cmd = "echo $text | iconv -f utf8 -t eucjp | kakasi -i euc -w | kakasi -i euc -Ha -Ka -Ja -Ea -ka"

os.system(cmd)

-------------------

The result was empty, as below:

Process finished with exit code 0

But, The result should be like below:

sukkiri wakaru Java nyuumon jissenhen dai 2 han

Help me.

1 Answer

0 votes
by (26.4k points)

Here, the text is a variable known to the python translator(interpreter) just; the shell you execute your order in has no clue about what $text is (it will assess to a vacant string). 

You can also try:

cmd = "echo '{}' | iconv ...".format(text)

that way you get your string to the order you need to execute. (can't test if there are different things that don't work...)

Are you pretty much interested to learn python in detail? Come and join the python training course to gain more knowledge.

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
asked Mar 30, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
0 votes
1 answer
asked Dec 3, 2020 in Python by laddulakshana (16.4k points)

Browse Categories

...