python中as用法實(shí)例分析

字號(hào):


    這篇文章主要介紹了python中as用法,實(shí)例分析了as的功能及相關(guān)使用技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    本文實(shí)例講述了python中as用法。分享給大家供大家參考。具體分析如下:
    import some # some 為一個(gè)模組
    如果想要改變被導(dǎo)入模組在當(dāng)前模組中的名稱(chēng),而不是sys.modules中的名稱(chēng)??梢允褂胕mport as,例如:
    import some as other
    print(other.name)
    和
    import some
    other = some
    del some
    print(other.name)
    一樣。
    希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。