我正在尝试使此代码将 prodname 变量转换为 int 值:
def prod_check(dirname):
prodname_to_prodnum = {}
fid2 = open('sample.txt','r')
line = fid2.readline()
line = line.strip()
pline = line.split(',')
prodname = (pline[0])[1:-1]
prodnum = prodname
prodname_to_prodnum[prodname] = prodnum
line = fid2.readline()
fid2.close()
但是当我使用“int(prodname)”时出现错误