运行test.py给出
Traceback (most recent call last):
File "test.py", line 3, in <module>
Map = Parser.Map(os.path[0] + "\\start.wmap")
TypeError: 'module' object is not subscriptable
import configparser
def StringIsNumber(String):
try:
int(String)
except:
return False
return True
class Map:
Parser = configparser.RawConfigParser()
MapURL = ""
def __init__(self, Map):
self.Parser.read(Map)
self.MapURL = Map
def TileTypes(self):
#All numerical sections can be assumed to be tiles
return [n for n in self.Parser.sections() if StringIsNumber(n)]
import Parser
import os
Map = Parser.Map(os.path[0] + "\\start.wmap")
print(Map.TileTypes())