我使用4個空格進行縮進,但出現語法錯誤。當我在文本編輯器中使用縮進時,工作正常。文本編輯器只創建1個塊,我無法編輯它。是否有空格不能用作縮進?用於縮進的4個空格 - 語法錯誤
def replace_line(file_name, line_num, text):
try:
lines = open(file_name, 'r').readlines()
lines[line_num] = text
out = open(file_name, 'w')
out.writelines(lines)
out.close()
if not var and not var2:
return
我得到的語法錯誤,如果不是var行。
請提供拋出錯誤的代碼。一般來說,空間非常好。 – Karin
從您的描述中,您聽起來像是混合了製表符和空格。 –