我正在处理的代码会引发错误Unsupported operand type(s) for +: 'WindowsPath' and 'str'
。我已经尝试了很多东西,但没有一个可以解决这个问题(除了删除有错误的行,但这没有帮助)。
对于上下文,此脚本(完成后)应该:
根据您输入的ID(在SongsPath.txt中指定的目录中)查找文件(mp3)
把它备份
然后用另一个文件替换它(重命名为上一个文件的名称)
以便获取这些文件的程序播放新歌曲而不是旧歌曲,但可以随时恢复到原始歌曲。(歌曲是从 newgrounds 下载的,并通过他们的 newgrounds 音频门户 ID 保存)
我正在使用 Python 3.6.5
import os
import pathlib
from pathlib import Path
nspt = open ("NewSongsPath.txt", "rt")
nsp = Path (nspt.read())
spt = open("SongsPath.txt", "rt")
sp = (Path(spt.read()))
print("type the song ID:")
ID = input()
csp = str(path sp + "/" + ID + ".mp3") # this is the line throwing the error.
sr = open(csp , "rb")
sw = open(csp, "wb")
print (sr.read())
慕妹3242003
慕无忌1623718
相关分类