1
我PrankHeader.py窗口錯誤:錯誤3]系統找不到指定的路徑:」 .prank /*.*顯示
import os
def removeNumber(str):
no_digit = []
for char in str:
if not char.isdigit():
no_digit.append(char)
return no_digit
def renameFiles():
saved_file = os.getcwd()
os.chdir("./prank")
# 1. loop through files in the directory
for files in os.listdir("./prank"):
# 2. if the file has the number, delete.
newFile = removeNumber(files)
# 3. make the list of char to string
newFile = ''.join(newFile)
os.rename(files, newFile)
os.chdir(saved_file)
而且我Prank.py
import PrankHeader
PrankHeader.renameFiles()
這兩個文件都在C:/ Users/Myname/Desktop/LocalServer/Prank文件夾中,並且文件夾中有包含圖片的文件夾Prank。
當我試圖執行程序這表明我 「窗口中的錯誤:錯誤3]系統找不到指定的路徑:‘.prank/’
有沒有誰知道我爲什麼有一個錯誤?
你做一個os.chdir(「Prankt)目錄惡作劇,然後在該目錄中,你做一個os.listdir(」./惡作劇「),但目錄惡作劇目錄中沒有目錄惡作劇,只需做一個listdir(」。「)然後它應該工作 – erik
實際上,惡作劇目錄中有一個惡作劇目錄第一個惡作劇是程序(用dirs和py),第二個惡作劇是包含一堆圖片的文件夾,我想改變他們的名字。 –