mac上使用什么软件编写python_在可编写脚本的应用程序中使用Python(在Mac上)

I'm quite new to programming, but I've learned some basic Python programming in a university course.

I'm looking for a way to run very simple Python scripts on Mac applications (mainly iTunes), in lieu of AppleScript. I've read up on using AppScript for Python, but it is no longer in development and is broken as of iTunes 10.6.3.

On my Windows computer, I was easily able to script applications with Python using a module called PyWin32. Since switching to a Mac, however, I haven't been able to find a good alternative. Here is an example script that I used on Windows, just to give an idea of the simplicity of the scripts I would like to use:

from win32com.client import Dispatch

iTunes = Dispatch("iTunes.Application")

selected_tracks = iTunes.SelectedTracks

track_count = selected_tracks.Count

for i in range(1, track_count + 1):

selected_tracks.Item(i).TrackNumber = i

selected_tracks.Item(i).TrackCount = track_count

As you can see, my scripting needs are quite basic, and I don't need any of the advanced event-handling features of something like AppScript. I plan on eventually learning AppleScript, but right now I still feel most comfortable with Python. Does anyone have any suggestions?

Thanks a lot!

解决方案

You need to use Scripting Bridge with PyObjC. There's rather a lot to it, but those links will get you started.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值