Results of executing hyperlink in script

MRAB google at mrabarnett.plus.com
Wed Jan 28 18:14:59 EST 2009


Muddy Coder wrote:
> Hi Folks,
> 
> My previous post got a many helps from the people, and I tested what
> they suggested. Since this topic maybe needed in future, so I drop
> these lines below to help the future programmers. The methods worked
> as below:
> 
> 1. This method was suggested by Cameron Laird:
> 
>       os.system("start %s" % URL)
> 
> It works. But, if the URL contains character &, it will fail. For
> example, if URL has only one field, such as: http://www.mydomain.com/ascript.cgi?user=muddy
> this method works well. But, if there more than one field need to be
> input, such as http://www.mydomain.com/ascript.cgi/user=muddy&password=foo,
> the field password failed to reach server, and the CGI script
> complained.
> 
You could put quotes around the URL:

os.startfile('"%s"' % URL)

or:

os.system('start "%s"' % URL)

if "&" has a special meaning to the command-line.



More information about the Python-list mailing list