如何使用 Python 在 GitHub Actions 中写入文件? [重复]

问题描述 投票:0回答:1

我想使用 GitHub Actions 将文本写入文件,但我不知道该怎么做。

我试过:

def write(path, text):
    file = open(path, 'w')
    file.write(text)
    file.close()

但什么都没有改变。

但是如果我在本地机器上运行它,它仍然有效。

python file github github-actions writefile
1个回答
-1
投票
def write(filename, text):

    with open(filename, 'w') as file:
        file.write(text)

filename = 'example.txt'

text = '12works!'

write(filename, text)

文本就是你要写入文件的内容

© www.soinside.com 2019 - 2024. All rights reserved.