【问题标题】:How to open files and applications on Python如何在 Python 上打开文件和应用程序
【发布时间】:2020-10-31 11:52:39
【问题描述】:

我有一些 Python 代码,我想打开一些文件、应用程序和文件夹。我试图用 sys 和 os 来做到这一点 -

sys.open('C:\\Users\\___\\!FILMS!')
os.open('C:\\Users\\___\\!FILMS!')

但它不起作用。请帮忙

【问题讨论】:

    标签: python windows operating-system sys


    【解决方案1】:

    读写(这里复制inputfile.txt -> outputfile.txt):

    import os
    
    with open("inputfile.txt", "r") as fin, open("outputfile.txt", "w") as fout:
        data = fin.read()
        # do something...
        fout.write(data)
    

    【讨论】:

    • 上面写着PermissionError: [Errno 13] Permission denied
    • 您需要检查您的文件权限...您是否拥有读取权限?
    猜你喜欢
    • 1970-01-01
    • 2015-07-04
    • 2021-10-28
    • 2019-06-22
    • 2015-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多