python读写

def code():
with open( 'test.txt', 'w', encoding= 'utf-8') as f:
for i in range( 0, 50000):
f.write( ' %s \n '% (random.randint( 0, 100000)))

code()



def getdistrictcode():
with open( 'test.txt') as file:
data = file.read()
districtlist = data.split( ' \n ')
global codelist
codelist = []
for node in districtlist:
#print node
codelist.append(node)
print(codelist[ 0])
print( len(codelist))

getdistrictcode()

你可能感兴趣的:(前端)