windows/ python-2.7/ path

i wanted to change the environment variable using python, but i need to load into the Windows Command Shell a variable which is stored in python.

I tried it like this :

userpath = 'C:/test_folder'
cmd = 'Path=%Path%; %s' % (userpath)
os.system(cmd)

But im am getting this error here : Traceback (most recent call last): File "J:\\Python_Script\\path_cahnge.py", line 7, in cmd = 'Path=%Path%; %s' % (userpath) ValueError: unsupported format character 'P' (0x50) at index 6

can someone help me with that ?

Thanks

暂无
暂无

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.

Related Question Changing python interpreter windows Changing video file properties with python Python Tkinter Changing the Colour of a Cursor Trouble changing the Python Interpreter in Windows Changing the position of the console window with Python (Windows) Changing prompt working directory via Python script Python Changing IP Address using WMI Changing microphone volume using Python, Windows 10 Problem with changing date to format DMMYYYY in Python Python: changing a string, based on it's original value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM