亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python 執行另一個文件

Python 執行另一個文件

慕工程0101907 2022-10-06 16:49:51
我制作了包含以下代碼的文件'DWDfunctional.py':def ForecastDownloader(system,ModelName,year,Month):     import cdsapi     c = cdsapi.Client()     c.retrieve(        'seasonal-monthly-single-levels',        {            'originating_centre': ModelName,            'system': system,            'variable': 'total_precipitation',            'product_type': 'monthly_mean',            'year': year,            'month': Month,            'area'          : [40, 44, 24, 64],            'leadtime_month': [                '1', '2', '3',                '4', '5', '6',            ],            'format': 'netcdf',        },        'dwd.nc')然后我在另一個文件中調用了該函數:from DWDfunctional.py import ForecastDownloaderForecastDownloader('2','dwd',2020,2)我想知道,當我運行上面兩行代碼時,python 在另一個文件夾中執行另一個舊代碼?。?!并以錯誤的文件名下載錯誤的文件,沒有錯誤!
查看完整描述

1 回答

?
楊魅力

TA貢獻1811條經驗 獲得超6個贊

導入后,您可以查看module.__file__您的module來源。

在您的特定情況下,您可以檢查ForecastDownloader.__file__是否應該為您提供正確的文件路徑。


查看完整回答
反對 回復 2022-10-06
  • 1 回答
  • 0 關注
  • 105 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號