我一直在嘗試在 mac 終端上運行一些 python,但遇到以下錯誤:“TypeError: 'module' object is not callable”
參考代碼:
import re
import pathlib as Path
mypath = Path('users/pranav/Desktop/sir/samplenames.txt')
有人可以為我分解錯誤并解釋我應該做些什么來解決它嗎?
我也嘗試使用 sys 修復它,但是,在我完成它之前,我收到了一條錯誤訊息:AttributeError:'list' object has no attribute 'dirname'
帶系統的代碼:
import sys
print(sys.path.dirname())
import re
import pathlib as Path
mypath = Path('/users/pranav/Desktop/sir/samplenames.txt')
任何幫助將不勝感激
uj5u.com熱心網友回復:
from pathlib import Path
SCR_DIR = 'C:\\users\\pranav\\Desktop\\sir'
mypath = Path(SRC_DIR, "samplenames.txt")
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/494292.html
