2014-03-06 45 views
0
# -*- coding: utf-8 -*- 
import easygui 
file = open("data.txt"[,"r+"]) 
Msg1 = easygui.multenterbox(title = 'ข้อมูล',fieldName=['ชื่อ','นามสกุล','ที่อยู่'] 
file.write(Msgl) 

運行這段代碼,我得到的錯誤無效的語法對象I/O

file.write(Msgl) 
    ^invalid syntax 

這又太

file = open("data.txt"[,"r+"]) 
^ 
SyntaxError: invalid syntax 
Script terminated. 

錯誤。的SyntaxError

+2

你錯過了一個右括號 –

+0

不是'open('a.x'[,'r +'])'也是無效的語法嗎? – zhangxaochen

回答

0

試試這個:

# -*- coding: utf-8 -*- 
import easygui 
file = open("data.txt"[,"r+"]) 
Msg1 = easygui.multenterbox(title = 'ข้อมูล',fieldName=['ชื่อ','นามสกุล','ที่อยู่']) 
file.write(Msgl) 

至於另一個海報說,你缺少一個右括號,它的包裝到下一行導致錯誤。