當前位置: 首頁>>代碼示例>>Python>>正文


Python Data.explore方法代碼示例

本文整理匯總了Python中Data.explore方法的典型用法代碼示例。如果您正苦於以下問題:Python Data.explore方法的具體用法?Python Data.explore怎麽用?Python Data.explore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Data的用法示例。


在下文中一共展示了Data.explore方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Main

# 需要導入模塊: import Data [as 別名]
# 或者: from Data import explore [as 別名]
def Main():
    if (not os.path.isdir(CONFIGDIR)):
        os.mkdir(CONFIGDIR)
    if (not os.path.isdir(SAVEDIR)):
        os.mkdir(SAVEDIR)

    planets = Data.loadPlanets(CONFIGDIR+"coords_planets.txt")
    planet_names = list(planets.keys())
    reservedwords = ["zone", "d", "help"] + planet_names

    commands = Core.readconfigfile(CONFIGDIR+"words.ini")
    
    #make sure that dictionnary contains all used keys and for all keys, each required subdictionnary is given
    requiredkeys = {"map":[], "save":[], "target":["delallexplored","removeall"], "view":[], "exit":[], "set-terre":[]}
    errmsg = ""
    for key in requiredkeys:
        if (key not in commands):
            commands[key] = {"words":key}
            errmsg += "- section "+key+" non trouvée\n"
        elif ("words" not in commands[key]):
            commands[key]["words"] = key
            errmsg += "- aucun mot pour la commande "+key+"\n"
        for subkey in requiredkeys[key]:
            if (subkey not in commands[key]):
                commands[key][subkey] = subkey
                errmsg += "- paramètre manquant dans la commande "+key+": "+subkey+"\n"
    #
    #get set of words for each command (instead of space-separated string)
    #keep only non reserved words, but at least one
    for key in commands:
        for subkey in commands[key]:
            commands[key][subkey] = set(commands[key][subkey].split())
            size = len(commands[key][subkey])
            Core.removefromlist(commands[key][subkey], reservedwords)
            if (len(commands[key][subkey]) != size):
                if (subkey == "words"):
                    errmsg += "- des mots réservés ont été supprimés pour la commande "+key+"\n"
                else:
                    errmsg += "- des mots réservés ont été supprimés pour le paramètre "+subkey+" dans la commande "+key+"\n"
            if (len(commands[key][subkey]) == 0):
                if (subkey == "words"):
                    commands[key][subkey].add(key)
                    errmsg += "- aucun mot pour la commande "+key+"\n"
                else:
                    commands[key][subkey].add(subkey)
                    errmsg += "- paramètre manquant dans la commande "+key+": "+subkey+"\n"
    #
    #use some standard words to exit prompt
    exitwords_reserved = ("quit", "exit")
    for exit_word in exitwords_reserved:
        if (not exit_word in commands["exit"]["words"]):
            commands["exit"]["words"].add(exit_word)
    #
    if (len(errmsg) > 0):
        printf("Problème(s) lors de la lecture du fichier words.ini:")
        printf(errmsg)
    playername = ""
    if (len(sys.argv) >= 2):
        playername = sys.argv[1].strip().lower()
    if (Core.isforbidden(playername) or playername in exitwords_reserved):
        playername = raw_input("Entrez votre pseudo: ")
    playername = playername.strip().lower()
    if (Core.isforbidden(playername)):
        printf("Erreur: ce pseudo est interdit")
        sys.exit(0)
    elif (playername in exitwords_reserved):
        sys.exit(0)
    playerdata = Data.load(playername)
    settings = playerdata[2]
    if (playername not in settings):
        settings[playername] = {}
    settings = settings[playername]
    if ("terre" in settings):
        planet_names = addTerre(settings, settings["terre"].split(), planets)
    Str = ""
    Strlist = []
    printf('Tapez "help" pour obtenir de l\'aide')
    try:
        exit = False
        while (not exit and not Core.oneIn(commands["exit"]["words"], Strlist)):
            Str = raw_input("> ").strip().lower()
            if (Str == ""):
                continue
            Strlist = Str.split(" ")
            try:
                if (Core.oneIn(commands["exit"]["words"], Strlist)):
                    exit = True
                if ("help" in Strlist):
                    print_help(Strlist, commands, planet_names, playername)
                elif (Core.oneIn(commands["map"]["words"], Strlist)):
                    Map.makeMap(playername, playerdata, planets)
                elif (Core.oneIn(commands["save"]["words"], Strlist)):
                    Data.save(playername, playerdata)
                elif (Core.oneIn(commands["view"]["words"], Strlist)):
                    os.system(Map.getMapFilename(playername))
                elif (Core.oneIn(commands["target"]["words"], Strlist) and not exit):
                    printf('Entrez vos nouveaux objectifs:')
                    while (not Core.oneIn(commands["exit"]["words"], Strlist)):
                        Str = raw_input("==> ").strip().lower()
                        if (Str == ""):
#.........這裏部分代碼省略.........
開發者ID:Spirou003,項目名稱:AlphaBounceMap,代碼行數:103,代碼來源:Main.py


注:本文中的Data.explore方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。