要獲取當前工作目錄,可以使用Python中的os模塊中的getcwd()函數。示例如下:
import os current_dir = os.getcwd() print("Current working directory:", current_dir)
運行上述代碼,將輸出當前工作目錄的路徑。