def tfunc(this.args.dir, folder):
for file in os.listdir(folder):
this.executeFile(os.path.join(this.args.dir, file))
def executeFiles(this):
for folders1 in os.listdir(this.args.dir):
for folders2 in os.listdir("downloaded/" os.path.join(folders1)):
t = threading.Thread(target=this.tfunc, args=(this, folders2))
t.start()
就像標題所說的那樣,我在最后一次爭論后嘗試了逗號,但無濟于事。我究竟做錯了什么?請幫忙。
編輯:可重現的代碼。抱歉沒有直接發布。現在我無法添加代碼,因為它說代碼太多而文本不夠,所以我在這里盡可能多地寫,以便能夠發布代碼。
class MoodysParser :
def complete(this) :
print(f"Complete")
exit()
def executeFile(this, filename):
print(filename)
def tfunc(dir, folder):
for file in os.listdir(folder):
this.executeFile(os.path.join(dir, file))
def executeFiles(this):
for folders1 in os.listdir(this.args.dir):
for folders2 in os.listdir("downloaded/" os.path.join(folders1)):
t = threading.Thread(target=this.tfunc, args=(this.args.dir, folders2))
t.start()
def execute(this) :
sys.setrecursionlimit(10000)
this.timestamp = int(time.time());
this.dir = os.path.dirname(__file__);
this.out_fn = f"moodys-results-{this.timestamp}.csv";
this.file_x = 1
this.fields_template = {};
this.fields_template["company"] = "";
this.fields_template["telephone"] = "";
this.fields_template["address"] = "";
this.fields_template["telephone2"] = "";
this.fields_template["link_id"] = "";
this.fields_template["location_type"] = "";
this.fields_template["industry"] = "";
this.fields_template["sales_range"] = "";
this.fields_template["employees"] = "";
this.fields_template["alerts_risk_increase"] = "";
this.fields_template["alerts_overall_payments"] = "";
this.fields_template["alerts_peer_payments"] = "";
this.fields_template["alerts_bankruptcy"] = "";
this.fields_template["alerts_tax_liens"] = "";
this.fields_template["alerts_financial_news"] = "";
this.fields_template["alerts_ucc_filings"] = "";
this.fields_template["number_reviews"] = "";
this.fields_template["average_rating"] = "";
this.fields_template["reviews"] = "";
this.firstrun = not os.path.isfile(this.out_fn)
this.out = open(this.out_fn, 'w', newline='', encoding="utf8");
print(f"Opening {this.out_fn}");
this.writer = csv.writer(this.out, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL);
this.out.write(b'\xEF\xBB\xBF'.decode())
this.writer.writerow(this.fields_template.keys());
parser = argparse.ArgumentParser()
parser.add_argument('--dir', type=str, required=True);
parser.add_argument('--max', type=int);
parser.add_argument('--debug', action=argparse.BooleanOptionalAction);
this.args = parser.parse_args();
if not os.path.isdir(this.args.dir):
print(f"Input directory does not exist")
exit()
this.executeFiles()
this.complete();
刮板 = MoodysParser(); scraper.execute();
uj5u.com熱心網友回復:
你不應該傳遞this給args. this將tfunc自動傳遞給。
t = threading.Thread(target=this.tfunc, args=(folders2, ))
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/523585.html
標籤:Python班级
下一篇:如何將文本檔案行放入串列
