2013-05-09 46 views
0

我無法弄清楚這個導入是什麼以及如何在python代碼中使用它。我是python的新手。Python代碼具有以下導入

import datasources.google as google 
+0

爲什麼不搜索「python import as」? – satoru 2013-05-09 05:51:10

回答

2

這行代碼導入模塊datasources.google。當您導入一個整體模塊import whatevermodule,你必須每次使用的東西從該模塊時,包括它,就像這樣:

datasources.google.dowhatever(thing) 

由於datasources.google是很長的,這將是不錯的一小段路寫它。這就是as google的一部分。這意味着你可以改爲寫:

google.dowhatever(thing) 

併爲您節省了一堆輸入。

2

而是寫作datasources.google.method的,你現在可以寫google.method,看到PEP221瞭解更多詳情...