本文整理汇总了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
示例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
示例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":