久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='PnSyE'><tr id='PnSyE'><dt id='PnSyE'><q id='PnSyE'><span id='PnSyE'><b id='PnSyE'><form id='PnSyE'><ins id='PnSyE'></ins><ul id='PnSyE'></ul><sub id='PnSyE'></sub></form><legend id='PnSyE'></legend><bdo id='PnSyE'><pre id='PnSyE'><center id='PnSyE'></center></pre></bdo></b><th id='PnSyE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PnSyE'><tfoot id='PnSyE'></tfoot><dl id='PnSyE'><fieldset id='PnSyE'></fieldset></dl></div>

  • <small id='PnSyE'></small><noframes id='PnSyE'>

  • <legend id='PnSyE'><style id='PnSyE'><dir id='PnSyE'><q id='PnSyE'></q></dir></style></legend>
      <tfoot id='PnSyE'></tfoot>

          <bdo id='PnSyE'></bdo><ul id='PnSyE'></ul>

        在 Python 中解析 CS:GO 腳本文件

        Parsing a CS:GO script file in Python(在 Python 中解析 CS:GO 腳本文件)
        • <bdo id='5E6i8'></bdo><ul id='5E6i8'></ul>

            <tbody id='5E6i8'></tbody>
            1. <tfoot id='5E6i8'></tfoot>
              <i id='5E6i8'><tr id='5E6i8'><dt id='5E6i8'><q id='5E6i8'><span id='5E6i8'><b id='5E6i8'><form id='5E6i8'><ins id='5E6i8'></ins><ul id='5E6i8'></ul><sub id='5E6i8'></sub></form><legend id='5E6i8'></legend><bdo id='5E6i8'><pre id='5E6i8'><center id='5E6i8'></center></pre></bdo></b><th id='5E6i8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5E6i8'><tfoot id='5E6i8'></tfoot><dl id='5E6i8'><fieldset id='5E6i8'></fieldset></dl></div>

                  <legend id='5E6i8'><style id='5E6i8'><dir id='5E6i8'><q id='5E6i8'></q></dir></style></legend>

                  <small id='5E6i8'></small><noframes id='5E6i8'>

                  本文介紹了在 Python 中解析 CS:GO 腳本文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在處理來自 CS:GO 的一些腳本文件,我必須從該文件中獲取一些有用的信息并將這些數據導入我的 python 應用程序.

                  I am working with some script files from CS:GO, I have to get some useful information from this file and import this data into my python application.

                  這里是一個txt數據格式的例子:

                  Here is an example of the txt data format:

                  https://steamcdn-a.akamaihd.net/apps/730/scripts/items/items_game.83a9ad4690388868ab33c627af730c43d4b0f0d9.txt

                  這些值采用隨機格式(ColorPosString),但我只需要一個包含所有值的字符串.我需要將此信息放入字典中,例如:

                  The values are in the random formats (ColorPosString), but i need just a string, which contains all of the values. I need to get this information into the dictionary for example:

                  print(global_dict['items_game']['game_info']['first_valid_class'])
                  <<2
                  

                  我現在正在研究解析器,但我遇到了很多問題.該文件格式是否有現成的解決方案?

                  I'm working on parser now, but I was faced with a lot of problems. Is there any ready solutions for that file format?

                  推薦答案

                  這是一個基于 pyparsing 的解析器,它將解析這種格式:

                  Here is a pyparsing-based parser that will parse this format:

                  from pyparsing import Suppress, QuotedString, Forward, Group, Dict, ZeroOrMore
                  
                  LBRACE,RBRACE = map(Suppress, "{}")
                  qs = QuotedString('"')
                  
                  # forward-declare value, since this expression will be recursive
                  # (will contain expressions which use contain value's)
                  value = Forward()
                  
                  key_value = Group(qs + value)
                  struct = LBRACE + Dict(ZeroOrMore(key_value)) + RBRACE
                  
                  # define content of value using <<= operator
                  value <<= qs | struct
                  
                  # define top-level parser
                  parser = Dict(key_value)
                  

                  將配置加載到字符串中,并調用 parser.parseString():

                  Load the config into a string, and call parser.parseString():

                  sample = open('cs_go_sample.txt').read()
                  config = parser.parseString(sample)
                  
                  print config.keys()
                  for k in config.items_game.keys():
                      print '-', k
                  
                  config.items_game.pprint()
                  

                  打印:

                  ['items_game']
                  - sticker_kits
                  - client_loot_lists
                  - prefabs
                  - quest_definitions
                  - alternate_icons2
                  - music_definitions
                  - rarities
                  - colors
                  - campaign_definitions
                  - player_loadout_slots
                  - quest_schedule
                  - item_levels
                  - revolving_loot_lists
                  - game_info
                  - pro_players
                  - recipes
                  - items_game_live
                  - paint_kits_rarity
                  - paint_kits
                  - qualities
                  - items
                  - attributes
                  - item_sets
                  - quest_reward_loot_lists
                  - kill_eater_score_types
                  
                  [['game_info',
                    ['first_valid_class', '2'],
                    ['last_valid_class', '3'],
                    ['first_valid_item_slot', '0'],
                    ['last_valid_item_slot', '54'],
                    ['num_item_presets', '4']],
                   ['rarities',
                    ['default',
                     ['value', '0'],
                  ... etc. ...
                  

                  編輯

                  如果您希望在解析時將整數值轉換為整數,您可以定義解析操作來執行此操作.但是您只想將此(我認為)附加到作為值的引用字符串,而不是作為鍵的字符串.

                  If you want the integer values to be converted to ints at parse time, you can define a parse action to do this. But you want to attach this (I think) only to the quoted strings that are values, not the ones that are keys.

                  # use this code to convert integer values to ints at parse time
                  key_qs = qs.copy()
                  value_qs = qs.copy()
                  def convert_integers(tokens):
                      if tokens[0].isdigit():
                          tokens[0] = int(tokens[0])
                  value_qs.setParseAction(convert_integers)
                  
                  value = Forward()
                  key_value = Group(key_qs + value)
                  struct = LBRACE + Dict(ZeroOrMore(key_value)) + RBRACE
                  value <<= value_qs | struct
                  parser = Dict(key_value)
                  

                  現在輸出值如下所示:

                  [['game_info',
                    ['first_valid_class', 2],
                    ['last_valid_class', 3],
                    ['first_valid_item_slot', 0],
                    ['last_valid_item_slot', 54],
                    ['num_item_presets', 4]],
                   ['rarities',
                    ['default',
                     ['value', 0],
                     ['loc_key', 'Rarity_Default'],
                     ['loc_key_weapon', 'Rarity_Default_Weapon'],
                  

                  請注意,整數值不再顯示為字符串,而是顯示為實際的 Python 整數.

                  Note that the integer values are not displayed as strings any more, but as actual Python ints.

                  這篇關于在 Python 中解析 CS:GO 腳本文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)
                      <tbody id='7bFLd'></tbody>
                    <i id='7bFLd'><tr id='7bFLd'><dt id='7bFLd'><q id='7bFLd'><span id='7bFLd'><b id='7bFLd'><form id='7bFLd'><ins id='7bFLd'></ins><ul id='7bFLd'></ul><sub id='7bFLd'></sub></form><legend id='7bFLd'></legend><bdo id='7bFLd'><pre id='7bFLd'><center id='7bFLd'></center></pre></bdo></b><th id='7bFLd'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7bFLd'><tfoot id='7bFLd'></tfoot><dl id='7bFLd'><fieldset id='7bFLd'></fieldset></dl></div>
                      <legend id='7bFLd'><style id='7bFLd'><dir id='7bFLd'><q id='7bFLd'></q></dir></style></legend>

                      <small id='7bFLd'></small><noframes id='7bFLd'>

                    1. <tfoot id='7bFLd'></tfoot>
                        • <bdo id='7bFLd'></bdo><ul id='7bFLd'></ul>
                            主站蜘蛛池模板: 成人国产一区二区三区精品麻豆 | 亚洲精品视频免费观看 | jav成人av免费播放 | 国产成人99久久亚洲综合精品 | 成人免费视频播放 | 亚洲精品免费视频 | 久久久免费观看视频 | 在线观看一区 | 欧美在线小视频 | 久久99精品久久久水蜜桃 | 日韩一区二区三区在线观看视频 | 亚洲精品无人区 | 中文字幕成人av | 国产精品一区久久久 | 日本激情视频网 | 免费的网站www | 日韩一区二区黄色片 | av黄色在线观看 | 国产免费色 | 午夜国产一级片 | 久久久久久久综合色一本 | 91亚洲精品久久久电影 | 日本在线精品视频 | a级在线免费 | 久久国产精品首页 | 中文字幕一区在线 | 国产在线www | 国产精品中文字幕在线 | 一区二区三区在线免费观看 | 欧美一区二区二区 | 国产成人免费视频网站高清观看视频 | 91精品国产欧美一区二区 | 免费不卡视频 | 国产精彩视频 | 国产98色在线 | 日韩精品在线视频免费观看 | 三级视频网站 | 成人av免费 | 91国产在线视频在线 | 亚洲三区视频 | 久久久久久国产 |