#!/usr/bin/python import sysconfig sysconfig_output_before = sysconfig._getuserbase() sysconfig_output_after = '\\'.join(sysconfig_output_before.split('/')) print sysconfig_output_before print sysconfig_output_after #### /home/user/PythonVirtualEnvironment/bin/python /home/user/Downloads/PythonProject/test.py /home/user/.local \home\user\.local #### 1. the directory from which the application loaded. 2. the current directory 3. the Windows system directory 4. the Windows directory 5. the directories in the PATH environment variable #### #!/usr/bin/perl use strict; use warnings; my $path_before = qx(/home/user/Downloads/PythonProject/test.py 2>&1); print "Befofe: " . $path_before; my $path_new = $path_before; $path_new =~ s{/}{\\}g; # Use s/\\/\//g; print "After: " . $path_new; __END__ perl test_2.pl Befofe: /home/user/.local After: \home\user\.local