0
我很新的Python,對不起,如果我是一個討厭,但我不斷收到這個錯誤,每當我嘗試我的代碼錯誤如下:Python的ubound方法錯誤
Traceback (most recent call last):<br>
File "<pyshell#3>", line 1, in <module>
fopen.open_file()
TypeError:<br> unbound method open_file() must be called with openFile instance as first argument (got nothing instead)
該計劃的目的是讀入用戶輸入的文件。
這裏是我的代碼:
class openFile:
def file_to_open():
fopen = raw_input('Enter the file path : ')
open_file = open(fopen)
print open_file
你爲什麼使用類? – timgeb
引發的異常與您的代碼不符。 –
你是怎麼用這個類來創建你的實例的? –