我正在尝试用Python编写一个简单的程序,它从我的Downloads文件夹中获取所有音乐文件并将它们放入我的Music文件夹中.我正在使用Windows,我可以使用cmd提示移动文件,但是我收到此错误:
WindowsError: [Error 2] The system cannot find the file specified
这是我的代码:
#! /usr/bin/python
import os
from subprocess import call
def main():
os.chdir("C:\\Users\Alex\Downloads") #change directory to downloads folder
suffix =".mp3" #variable holdinng the .mp3 tag
fnames = os.listdir('.') #looks at all files
files =[] #an empty array that will hold the names of our mp3 files
for fname in fnames:
if fname.endswith(suffix):
pname = os.path.abspath(fname)
#pname = fname
#print pname
files.append(pname) #add the mp3 files to our array
print files …Run Code Online (Sandbox Code Playgroud)