当前位置: 首页>>代码示例>>Python>>正文


Python Scanner.close方法代码示例

本文整理汇总了Python中scanner.Scanner.close方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.close方法的具体用法?Python Scanner.close怎么用?Python Scanner.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scanner.Scanner的用法示例。


在下文中一共展示了Scanner.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: buildMatrix

# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import close [as 别名]
def buildMatrix(fname, rows, cols):
   # Construct an empty matrix with specified rows and cols
   matrix = []
   for i in range(0, rows):
       matrixCols = []
       for i in range(0, cols):
           matrixCols.append(0)
       matrix.append(matrixCols)

   # Open the file using Scanner or File Pointer
   # scanner example from http://troll.cs.ua.edu/cs150/projects/practice1.html
   if (fname):
       s = Scanner(fname)
       
       # Read the data from each row into an array
       scannedArray = []
       token = s.readtoken()
       while token != '':
           scannedArray.append(token)
           token = s.readtoken()

       # Append the array onto the matrix
       for rowNumber in range(0, len(matrix)):
           for columnNumber in range(0, len(matrix[rowNumber])):
               if (len(scannedArray) > 0):
                   matrix[rowNumber][columnNumber] = scannedArray.pop(0)

       # Close the file
       s.close()

   return matrix
开发者ID:mdpatrick,项目名称:game_of_life,代码行数:33,代码来源:life.py

示例2: readTable

# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import close [as 别名]
def readTable(filename):
    s = Scanner(filename)
    table = []
    record = readRecord(s)
    while record != "":
        table.append(record)
        record = readRecord(s)
    s.close()
    return table
开发者ID:VikasNeha,项目名称:Student_Assignments,代码行数:11,代码来源:twittersort.py

示例3: QueueSLL

# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import close [as 别名]
        values = QueueSLL()
        try:
            scan = Scanner(filename)
        except IOError:
            print("file not found")
            input()
            continue
        while True:
            nextInt = scan.readint()
            if nextInt == "":
                break
            if type(heap) == HeapBT:
                values.enqueue(BinaryNode(nextInt))
            else:
                values.enqueue(nextInt)
        scan.close()
        heap.readData(values)

    elif option == "v":
        if heap.peek() == None:
            print("Error: the tree is empty")
            input()
        else:
            if type(heap) == HeapBT:
                gw = TreeGraphWriter("graph", heap)
            else:
                gw = ArrayGraphWriter("graph", heap)
            gw.createGraph()
            gw.display()

    elif option == "s":
开发者ID:,项目名称:,代码行数:33,代码来源:


注:本文中的scanner.Scanner.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。