gpt4 book ai didi

python - 为什么 print 语句在 python 中产生一个没有任何标签的换行符?

转载 作者:太空宇宙 更新时间:2023-11-04 00:49:46 25 4
gpt4 key购买 nike

这是代码 -

import os

file = open("list.txt", "rw+")
text = file.readline()
print "ffmpeg -loop 1 -i image.jpg -i \""+text+"\" -vf scale=1280:720 -shortest -acodec copy -vcodec mpeg4 \""+text+".mp4\""

os.system("ffmpeg -loop 1 -i image.jpg -i \""+text+"\" -vf scale=1280:720 -shortest -acodec copy -vcodec mpeg4 \""+text+".mp4\"")

但是输出是这样的:

ffmpeg -loop 1 -i image.jpg -i "some-file-path
" -vf scale=1280:720 -shortest -acodec copy -vcodec mpeg4 "some-file-path"

它应该在一行中

然后 ffmpeg 抛出文件不存在的错误!

最佳答案

因为你的文件在行尾有换行符('\n'),
所以 text"some-file-path\n"

您应该将 text = file.readline() 更改为 text = file.readline().strip()

关于python - 为什么 print 语句在 python 中产生一个没有任何标签的换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37599746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com