Hi I am trying to check for java version by using below python code
os.environ["PATH"] = os.environ["PATH"] + os.pathsep + "C:\Program Files\Java\jdk1.8.0_20\bin"
os.system("java -version")
but it shows this error message
'java' is not recognized as an internal or external command, operable program or batch file.
'\\b'
is a BACKSPACE character, not \\
and b
.
>>> "\b"
'\x08'
>>> print("\b")
To represent \\
and b
literally, you need to escape \\
, or use r'raw string literal'
:
>>> print("\\b")
\b
>>> print(r"\b")
\b
I tried to print the PATH
os.system("echo %PATH%")
then I found some weird text like below
C:\Program Files\Java\jdk1.8.0_20in
\\b in \\bin is showing as backspace char in path
replace path with below works fine
C:\\Program Files\\Java\\jdk1.8.0_20\\bin
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.