0
import os path = os.getcwd() os.system('powershell.exe $env:path += "' + path + '\\ProgramFiles"') 

This outputs as $env:path += c:\programfiles

And therefore returns as an error. Can someone explain why it removes the Quotation mark from the string and a possible solution?

2 Answers 2

1

Use raw strings, by inserting an r character before the quotes which start the string:

import os path = os.getcwd() os.system(r'powershell.exe $env:path += \"' + path + r'\\ProgramFiles\"') 
Sign up to request clarification or add additional context in comments.

Comments

0

If you want to write a double quote inside a string delimited by double quotes you need to escape it. Try this -

import os path = os.getcwd() os.system('powershell.exe $env:path += \"' + path + '\\ProgramFiles\"') 

1 Comment

But the string in the question is not delimited by double quotes...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.