python - Writing Array to txt file with requested name -


The following is a problem with writing an array for the file whose name is entered by the user:

  Diff main (): #file opens #fh = open "A5Nums.txt", "r") array = [] # reads the number in an array in fh.readlines () for line: in line.split () I: array.append (int (i)) # print The array prints ( Rni) # array reverse the array. Reverse () reverses the array (array) # Close the input file fh.close () Main ()   

After reversing the array, I want the user to output the file A name will be requested and then the file will be saved according to what they have recorded, any help would be appreciated! Thanks!

You can get the user in Python 3.x

  Outfile = input ("Please name your output file")   

or python 2.x

  outfile = raw_input ("Please enter your name Outfile, as "W +"): strArray = list (with map (str, array)  
  write   

)) FotWitLines (Strawley)

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -