我有以下代碼:基本上我在做什麼,正在尋找一個.csv文件,它可能位於兩個位置之一(或更依賴) 我有一個文本文件(LocationsFile.txt).
打開文件錯誤:TypeError:強制爲Unicode:需要字符串或緩衝區,找到列表
出於此我只想得到該學生特定領域的兩個具體位置:這是SSID Field
我有下面的代碼,但錯誤它似乎給我如下:
Tape Name130322
['\\\\....HIDDEN FOR Confidenciality .....StudentDB1_av.csv']
Success:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "C:\Users\Administrator\Desktop\John\Spreadsheet\Gui.py", line 291, in run
findStudentData('130322','StudentDB1')
File "C:\Users\Administrator\Desktop\John\Spreadsheet\Gui.py", line 62, in findStudentData
with open(items) as f:
TypeError: coercing to Unicode: need string or buffer, list found
正在執行的代碼如下: - 請在回答時留心體貼,因爲我是'新手'python程序員!
def findStudentData(student_name,course):
student_name= student_name.lower()
configfiles = []
print "student_name" + student_name
for path in MMinfo_paths:
configfiles.append(glob.glob(path+"/" + course+"*"))
for items in configfiles:
print items
print "Success:"
heading = True
with open(items) as f:
content = f.read()
if heading == True
ssidCol = content.index('ssid')
flagsCol = content.index('flags')
nameCol = content.index('name')
heading = False
continue
for item in rowData:
if rowData.index(item) == nameCol:
print rowData
else:
continue
非常感謝:-)
縮進是有點過 –
忽略的是一分鐘。 :-) – KingJohnno
請發佈錯誤消息的完整回溯 –