-1
所以我已經有了這種在ftp上查找特定jpgs的非常糟糕的方法。 它找到我有一個excel文件並檢查ftp。 你們會如何讓這個更正確的更快/更容易/更普遍?替代在FTP服務器上查找文件?
ftp = FTP("ftp.helmethouse.com")
g=ftp.login(user ='username',passwd = 'password')
wb = openpyxl.load_workbook(r'C:\Users\aaron\Documents\HustleHardRacing\Shoei HJC Colors only.xlsx')
sheet = wb.get_sheet_by_name('Shoei HJC full colors and sizes')
def check_line_for_img(line):
for i in range(2,143):
x = sheet.cell(row =i, column = 3).value
k = ['r.jpg', 'top.jpg', 't.jpg', 'rer.jpg', 'rt.jpg']
line = line[56:]
if x is None:
pass
else:
for i in range(len(k)):
y = (x[:-2]+'03'+k[i])
print(y)
if line == y:
print(line)
elif y is None:
print ('Error!')
pass
else:
pass
k = ftp.retrlines('LIST', check_line)
定義 「更普遍的」 –
注:如果這個代碼不以某種方式破解,請嘗試在此處詢問https://codereview.stackexchange.com/tour –
我會問「一般來說,搜索特定值的項目列表的最佳做法是什麼。」但我可能只是去找我自己 –