我可以使用python吗??? [英] Can I use python for this .. ??

查看:90
本文介绍了我可以使用python吗???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我使用的是Windows XP并安装了python和win32。我是熟悉基本Python的b $ b。我想通过python脚本控制一些

应用程序。


我想编写一个python脚本来说:

1.打开firefox并登录gmail

2.另一个访问slickdeals的firefox窗口

3.打开winamp并收听shoutcast站

4.打开分组...

等..


这些是我每天登录计算机时所做的任务..它

看似重复,因此可能用python编码。


我可以在python中执行此操作吗?我在哪里可以找到所有这些不同程序的COM对象/接口?有没有示例代码?


谢谢。

Santosh。

Hi

I am using windows xp and have installed python and win32. I am
familiar with basic Python. I wanted to control some of the
applications via python script.

I would like to write a python script to say:
1. Open firefox and log on to gmail
2. Another firefox window to visit slickdeals
3. Open winamp and tune in to a shoutcast station
4. Open groupwise ...
etc ..

These are the task I do every day whenever I log on my computer .. it
just seems repetitive and hence probably can be coded in python.

Can I do this in python? Where do I find the COM objects/interfaces for
all these different programs? Are there any sample codes ?

Thanks.
Santosh.

推荐答案

顺便说一句,我得到了firefox打开并访问了一些网页和winamp

正在运行..


以下代码

----------

导入os

导入os.path

导入子流程

#网页

ffox_exe = r''C:\程序文件\ Mozilla Firefox \ firefox.exe''

断言os.path .exists(ffox_exe)

#open gmail

url =" http://www.gmail.com"

child = subprocess。 Popen((ffox_exe,url),executable = ffox_exe)

rc = child.wait()


#Winamp

wamp_exe = r''C:\Program Files \Winamp \winamp.exe''

断言os.path.exists(wamp_exe)

url =" http ://64.236.34.97:80 / stream / 1040"

child = subprocess.Popen((wamp_exe,url),executable = wamp_exe)


------------


现在无论如何我可以输入用户名和密码,然后点击

好​​吧..(不适用于gmail,但适用于需要

loggin的其他类似网页).. ??


如何打开页面在标签.. ??


San

btw i got the firefox to open and access some webpage and winamp
running ..

code below
----------
import os
import os.path
import subprocess

# Web pages
ffox_exe = r''C:\Program Files\Mozilla Firefox\firefox.exe''
assert os.path.exists(ffox_exe)
# open gmail
url = "http://www.gmail.com"
child = subprocess.Popen( (ffox_exe, url), executable = ffox_exe)
rc = child.wait()

# Winamp
wamp_exe = r''C:\Program Files\Winamp\winamp.exe''
assert os.path.exists(wamp_exe)
url = "http://64.236.34.97:80/stream/1040"
child = subprocess.Popen( (wamp_exe, url), executable = wamp_exe)

------------

now is there anyway i can enter user name and password and then click
okay .. (not for gmail but for other similar webpages which require
loggin) .. ??

how to open pages in tabs .. ??

San


对于初学者,你需要os和webbrowser模块


导入os

导入webbrowser


webbrowser.open(" http://mail.google.com/邮件")


#需要知道用于启动应用程序的shell关键字

os.system(''start''+''Winword'')


#相当于双击文档或文件

os.startfile(" c:/MyFiles/MyTextFile.txt")


如果你真的想登录受密码保护的网站,它会快速获得
(超出我的范围)。您可以通过仔细阅读urllib2

模块或在groups.google.com/group/comp.lang.python上搜索此列表来了解



rick

For starters, you need the os and webbrowser modules

import os
import webbrowser

webbrowser.open("http://mail.google.com/mail")

# need to know the shell keyword for starting the app
os.system(''start '' + ''Winword'')

# the equivalent of double-clicking on the doc or file
os.startfile("c:/MyFiles/MyTextFile.txt")

If you actually want to log onto password-protected sites it gets
gnarly fast (beyond me). You can read about by perusing the urllib2
module or search this list at groups.google.com/group/comp.lang.python

Hope this helps.

rick


为什么要使用Python?

怎么样?

1.在控制面板中打开电源选项。 (单击开始,单击控制

面板,然后双击电源选项。)

2.单击Hibernate选项卡,选择启用hibernate支持检查

框,然后单击Apply。

(如果Hibernate选项卡不可用,则您的计算机不支持

此功能。)


然后:

1:单击开始和关机,

2:指向待机按钮并按住Shift键,

3:出现一个新的休眠按钮:点击它同时仍然按住

shift键:瞧你的电脑将休眠(它的男士电脑会保存

你当前的设置并将关闭)。


Petr Jakes

Why using Python?
What about?
1. Open Power Options in Control Panel. (Click Start, click Control
Panel, and then double-click Power Options.)
2.Click the Hibernate tab, select the Enable hibernate support check
box, and then click Apply.
(If the Hibernate tab is unavailable, your computer does not support
this feature.)

then:
1: Click Start and Shut Down,
2: Point the standby button and maintain the shift key pushed,
3: A new hibernation button appears: click it while still holding the
shift key: voila your PC will hibernate (it mens computer will save
your current setting and will switch off).

Petr Jakes


这篇关于我可以使用python吗???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆