狀態真是duang的不行。 boolan的兩個課程真是跟的想吐。OC完了是swift全是語法一臉懵逼,好在C++底子。虛擬機傷不起。依然要上黑蘋果了 前端課程的邏輯清晰點,互動也相對好一些。 靜態網頁 熟悉CSS框中框有啥難得,另外不會了用開發者模式去網站上去抄。只是javascript后面的課程難度咋樣不知道
python~ 自帶shell兼職是垃圾,help出來的文檔也是跪了真懷疑是不是國人寫的文檔。。。 python還真是急簡,變量不用指明類型直接判斷。連var auto什么的直接省了 簡直6666 for in 循環也是套起來直接用。
try: with open('sketch.txt','r') as file_in: for each_line in file_in: try: (spoken,spoken_context) = each_line.split(':',1) spoken_context.strip() if spoken == 'Man': man.append(spoken_context) if spoken == 'Other Man': other.append(spoken_context) except ValueError as err: #后臺實現邏輯是這樣的,打開方式’r’ ‘rb’會決定 file_in中的取值。file_in是否就為一個list里面存儲為str呢? 返回值是什么? file_in.readline() 函數 很明顯 file_in仍然是一個文件對象,那么問題應該是就是在“for in”語句里面。在Object-C中對象要支持for in循環必須要支持for-in的協議,實現該接口。其次。循環直接用 for each_line in file_in each_line是一個str。那么python在for in是否也加入了某些處理方式,才得到each_line這個str? try: with open('sketch.txt','rb') as file_in: for each_line in file_in: try: (spoken,spoken_context)=each_line.split(':',1) spoken_context.strip() if spoken == 'Man': man.append(spoken_context) if spoken == 'Other': other.append(spoken_context) except ValueError as err: print('value error'+str(err)) pass except IOError as err: print('file err'+str(err))`這段代碼會提示錯誤,原因是”rb”的打開方式。
Traceback (most recent call last): File "<pyshell#54>", line 5, in <module> (spoken,spoken_context)=each_line.split(':',1)TypeError: a bytes-like object is required, not 'str'后臺實現邏輯是這樣的,打開方式’r’ ‘rb’會決定 file_in中的取值。file_in是否就為一個list里面存儲為str呢? 返回值是什么? file_in.readline() 函數 很明顯 file_in仍然是一個文件對象,那么問題應該是就是在“for in”語句里面。在Object-C中對象要支持for in循環必須要支持for-in的協議,實現該接口。其次。循環直接用 for each_line in file_in each_line是一個str。那么python在for in是否也加入了某些處理方式,才得到each_line這個str? 如上,a bytes-like object is requied ,not ‘str’。 這里的each_line是按二進制的方式打開的數據,賦值與變量each_line 再調用split 自然會發生錯誤~
|
新聞熱點
疑難解答