Reputation: 2023
I've had a piece of code which basically read a txt file from directory.
def img2vector(filename):
returnVect=zeros((1,1024))
fr=open(filename)
for i in range(32):
lineStr=fr.readline()
for j in range(32):
returnVect[0,32*i+j]=int(lineStr[j])
return returnVect
When I run img2vector(PATHTOMYFILE) I've got the error message:
fr=open(filename) TypeError: function takes at least 2 arguments (1 given)
But, when I try:
fr=open(PATHTOMYFILE)
it's correct without any problem.
Upvotes: 2
Views: 2440
Reputation: 11
You must have imported both os and numpy
You can do
from numpy import *
import operator
import os
Upvotes: 0