Help!Unknown ERROR - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Help!Unknown ERROR (/thread-26066.html) |
Help!Unknown ERROR - bwdu - Apr-20-2020 Hello, everyone! I am trying to run this to program together but unfortunately ı get en ERROR that I dont't know. Can you help me? randomintseq.py m = int(sys.argv[1]) n = int(sys.argv[2]) for i in range(n): a = random.randint(0, m-1) print(a)tenperline.py file = open("filtereddata.txt","w") b = [list(range(x,x+10)) for x in range(0, 100, 10)] print(b) #headings i = "|0|" i1 = "|1|" i2 = "|2|" i3 = "|3|" i4 = "|4|" i5 = "|5|" i6 = "|6|" i7 = "|7|" i8 = "|8|" i9 = "|9|" format_string = "%-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d %-4d\n" text1 = ("%-4s %-4s %-4s %-4s %-4s %-4s %-4s %-4s %-4s %-4s\n" % (i, i1, i2, i3, i4, i5, i6, i7, i8, i9 )) text2 = (format_string % (b[0][0], b[0][1], b[0][2], b[0][3], b[0][4], b[0][5], b[0][6], b[0][7], b[0][8], b[0][9])) text3 = (format_string % (b[1][0], b[1][1],b[1][2] , b[1][3], b[1][4], b[1][5], b[1][6], b[1][7], b[1][8], b[1][9])) text4 = (format_string % (b[2][0], b[2][1], b[2][2], b[2][3], b[2][4], b[2][5], b[2][6], b[2][7], b[2][8], b[2][9])) text5 = (format_string % (b[3][0], b[3][1], b[3][2], b[3][3], b[3][4], b[3][5], b[3][6], b[3][7], b[3][8], b[3][9])) text6 = (format_string % (b[4][0], b[4][1], b[4][2], b[4][3], b[4][4], b[4][5], b[4][6], b[4][7], b[4][8], b[4][9])) text7 = (format_string % (b[5][0], b[5][1], b[5][2], b[5][3], b[5][4], b[5][5], b[5][6], b[5][7], b[5][8], b[5][9])) text8 = (format_string % (b[6][0], b[6][1], b[6][2], b[6][3], b[6][4], b[6][5], b[6][6], b[6][7], b[6][8], b[6][9])) text9 = (format_string % (b[7][0], b[7][1], b[7][2], b[7][3], b[7][4], b[7][5], b[7][6], b[7][7], b[7][8], b[7][9])) text10 = (format_string % (b[8][0], b[8][1], b[8][2], b[8][3], b[8][4], b[8][5], b[8][6], b[8][7], b[8][8], b[8][9])) text11 = (format_string % (b[9][0], b[9][1], b[9][2], b[9][3], b[9][4], b[9][5], b[9][6], b[9][7], b[9][8], b[9][9])) file.write(text1) file.write(text2) file.write(text3) file.write(text4) file.write(text5) file.write(text6) file.write(text7) file.write(text8) file.write(text9) file.write(text10) file.write(text11)filtereddata.txt |0| |1| |2| |3| |4| |5| |6| |7| |8| |9| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 When wrote this to cmd; >randomintseq.py 200 100 | tenperline.py > filtereddata.txt I got this error; Traceback (most recent call last): File "C:\Users\USER\Desktop\app\tenperline.py", line 10, in <module> file = open("filtereddata.txt","w") PermissionError: [Errno 13] Permission denied: 'filtereddata.txt' If you have any idea about how to fix this i will be so appriciated. RE: Help!Unknown ERROR - deanhystad - Apr-20-2020 Your program is reading from and writing to the same file. It should be reading from and writing to a pipe. https://docs.python.org/3/library/pipes.html |