当前位置: 首页 > news >正文

python打不开txt文件苹果怎么打开_如何在Mac上的Python中从TextEdit中打开文本文......

您可以使用/usr/bin/open OSX实用程序:

NAME

open -- open files and directories

SYNOPSIS

open [-e] [-t] [-f] [-F] [-W] [-R] [-n] [-g] [-h] [-b bundle_identifier] [-a application] file ... [--args arg1 ...]

DESCRIPTION

The open command opens a file (or a directory or URL), just as if you had double-clicked the file's icon. If no application name is specified, the default application as deter-

mined via LaunchServices is used to open the specified files.

If the file is in the form of a URL, the file will be opened as a URL.

You can specify one or more file names (or pathnames), which are interpreted relative to the shell or Terminal window's current working directory. For example, the following com-

mand would open all Word files in the current working directory:

open *.doc

Opened applications inherit environment variables just as if you had launched the application directly through its full path. This behavior was also present in Tiger.

您还应该使用subprocess module而不是os.system,因为避免转义问题更加容易:

import subprocess

subprocess.call(['open', '-a', 'TextEdit', file])

相关文章:

  • 如何使用python编程抢京东优惠券 知乎_小猿圈Python之实现京东秒杀功能代码
  • 预警系统一键自动升级程序_带有L2级自动驾驶技术,本田思域的起售价为11.99万...
  • python删除列表中的偶数_从奇数/偶数Python列表中删除偶数/奇数
  • ehcache使用_技术分享|浅谈EhCache实现页面缓存和数据缓存
  • elasticsearch date_史上最全的ElasticSearch系列之基础
  • python字符串函数参数_python:字符串常用函数
  • fabric白皮书_安全: Intel发布CSME安全白皮书
  • resnet50能用cpu跑吗_锐龙5000上市倒计时 官方告诉你哪些主板能用
  • web个人主页制作代码_Web前端开发是干嘛的?Web前端工资一般多少?
  • java动态代理_Java 动态代理及 RPC 框架介绍
  • 关于python的赋值说法_Python中tuple+=赋值的四个问题
  • python如何截取日期中的月份_python – 从给定日期开始提取日,月和年的...
  • python3 beautifulsoup_(转载) python3: beautifulsoup的使用
  • 为什么除零错会导致程序崩溃_Firefox 76.0.1紧急发布:修复导致部分扩展程序崩溃问题...
  • python3 zipfile解压出错_解决python3中解压zip文件是文件名乱码的问题
  • @angular/forms 源码解析之双向绑定
  • 《Javascript高级程序设计 (第三版)》第五章 引用类型
  • 【翻译】babel对TC39装饰器草案的实现
  • 4. 路由到控制器 - Laravel从零开始教程
  • CSS进阶篇--用CSS开启硬件加速来提高网站性能
  • Fundebug计费标准解释:事件数是如何定义的?
  • Go 语言编译器的 //go: 详解
  • Golang-长连接-状态推送
  • Laravel 中的一个后期静态绑定
  • mysql 数据库四种事务隔离级别
  • node入门
  • Python连接Oracle
  • React的组件模式
  • 从PHP迁移至Golang - 基础篇
  • 干货 | 以太坊Mist负责人教你建立无服务器应用
  • 记一次删除Git记录中的大文件的过程
  • 检测对象或数组
  • 坑!为什么View.startAnimation不起作用?
  • 前端之React实战:创建跨平台的项目架构
  • 如何用vue打造一个移动端音乐播放器
  • 数据可视化之 Sankey 桑基图的实现
  • 通过npm或yarn自动生成vue组件
  • 消息队列系列二(IOT中消息队列的应用)
  • C# - 为值类型重定义相等性
  • 宾利慕尚创始人典藏版国内首秀,2025年前实现全系车型电动化 | 2019上海车展 ...
  • (20)目标检测算法之YOLOv5计算预选框、详解anchor计算
  • (22)C#传智:复习,多态虚方法抽象类接口,静态类,String与StringBuilder,集合泛型List与Dictionary,文件类,结构与类的区别
  • (6)STL算法之转换
  • (附源码)springboot青少年公共卫生教育平台 毕业设计 643214
  • (附源码)springboot优课在线教学系统 毕业设计 081251
  • (九)One-Wire总线-DS18B20
  • (强烈推荐)移动端音视频从零到上手(上)
  • (十)【Jmeter】线程(Threads(Users))之jp@gc - Stepping Thread Group (deprecated)
  • (十八)三元表达式和列表解析
  • (原创)Stanford Machine Learning (by Andrew NG) --- (week 9) Anomaly DetectionRecommender Systems...
  • (转)Groupon前传:从10个月的失败作品修改,1个月找到成功
  • ..回顾17,展望18
  • .bat批处理(十):从路径字符串中截取盘符、文件名、后缀名等信息
  • .net core 6 集成和使用 mongodb
  • .NET 中使用 Mutex 进行跨越进程边界的同步