Python doesn't understand %userprofile%
Mike Driscoll
kyosohma at gmail.com
Wed Jun 11 07:47:29 EDT 2008
On Jun 11, 1:58 am, Tim Roberts <t... at probo.com> wrote:
> bsag... at gmail.com wrote:
>
> >In xp when I try os.path.getmtime("%userprofile/dir/file%") Python
> >bites back with "cannot find the path specified" Since my script has
> >to run on machines where the username is unspecified I need a fix.
>
> For the record, the %PERCENT% syntax for looking up an environment variable
> is just a feature of the XP command shell. It has no meaning to any other
> part of Windows.
>
> os.environ is the right answer.
> --
> Tim Roberts, t... at probo.com
> Providenza & Boekelheide, Inc.
You can use it at the Run command or in Explorer too. If I type
%username% in either place, it opens the following on my XP machine: C:
\Documents and Settings\Mike
Mike
More information about the Python-list
mailing list