新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python用import報錯如何解決
一個文件夾下的同一級的文件,import 時卻無法導(dǎo)入,為什么呢?

成都創(chuàng)新互聯(lián)是專業(yè)的海拉爾網(wǎng)站建設(shè)公司,海拉爾接單;提供成都網(wǎng)站制作、成都網(wǎng)站設(shè)計、外貿(mào)營銷網(wǎng)站建設(shè),網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進行海拉爾網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
import不成功就是因為路徑?jīng)]對應(yīng),事實上是pycharm默認該項目的根目錄為source目錄,所以import使用絕對路徑而不是相對路徑的話,就會從項目的根目錄中查找,而不是我們希望的其中的/src目錄,所以import不成功。
解決方法
關(guān)鍵點在于mark as sources 的是py 文件所在的文件夾目錄,緊接著開始調(diào)用函數(shù)了。
網(wǎng)站標題:創(chuàng)新互聯(lián)Python教程:python用import報錯如何解決
本文地址:http://fisionsoft.com.cn/article/dhjgcjg.html


咨詢
建站咨詢
