关于python的单引号使用问题
以下是我的代码:importwxdefload(event):file=open(filename.Getvale())contents.SetValue(file,re...
以下是我的代码:
import wx
def load(event):
file=open(filename.Getvale())
contents.SetValue(file,read())
file.close()
def save(event):
file=open(filename.GetValue().'w')
file=write(contents.GetValue())
file.close()
app=wx.App()
win=wx.Frame(None,title="Simple Editor",size=(410,335))
bkg=wx.Panel(win)
loadButton=wx.Button(bkg,lable='Open')
loadButton.Bind(wx.EVT_BUTTON,load)
saveButton=wx.Button(bkg,label='Open')
saveButton.Bind(wx.EVT_BUTTON,sve)
filename=wx.TextCtrl(bkg)
content=wx.TextCtrl(bkg,style=wx.TE_MULTILINE|wx.HSCROLL)
hbox=wx.BoxSizer()
hbox.Add(filename,proportion=1,flag=wx.EXPAND)
hbox.Add(loadButton,proportion=0,flag=wx.LEFT,border=5)
hbow.Add(saveButton,proportion=0,flag=wx.LEFT,border=5)
vbox=wx.BoxSizer(wx.VERTICAL)
vbox.Add(hbox,proportion=0,flag=wx.EXPAND|wx.ALL,border=5)
vbow.Add(contents,proportion=1,
flag=wx.EXPAND|wx.LEFT|wx.BOTTON|wx.RIGHT,border=5)
bkg.SetSizer(vbox)
win.Show()
app.MainLoop()
为什么无论是当我整体运行时,还是单行敲命令是总是提示一个错误
求高手指点迷津!!多谢帮助!! 展开
import wx
def load(event):
file=open(filename.Getvale())
contents.SetValue(file,read())
file.close()
def save(event):
file=open(filename.GetValue().'w')
file=write(contents.GetValue())
file.close()
app=wx.App()
win=wx.Frame(None,title="Simple Editor",size=(410,335))
bkg=wx.Panel(win)
loadButton=wx.Button(bkg,lable='Open')
loadButton.Bind(wx.EVT_BUTTON,load)
saveButton=wx.Button(bkg,label='Open')
saveButton.Bind(wx.EVT_BUTTON,sve)
filename=wx.TextCtrl(bkg)
content=wx.TextCtrl(bkg,style=wx.TE_MULTILINE|wx.HSCROLL)
hbox=wx.BoxSizer()
hbox.Add(filename,proportion=1,flag=wx.EXPAND)
hbox.Add(loadButton,proportion=0,flag=wx.LEFT,border=5)
hbow.Add(saveButton,proportion=0,flag=wx.LEFT,border=5)
vbox=wx.BoxSizer(wx.VERTICAL)
vbox.Add(hbox,proportion=0,flag=wx.EXPAND|wx.ALL,border=5)
vbow.Add(contents,proportion=1,
flag=wx.EXPAND|wx.LEFT|wx.BOTTON|wx.RIGHT,border=5)
bkg.SetSizer(vbox)
win.Show()
app.MainLoop()
为什么无论是当我整体运行时,还是单行敲命令是总是提示一个错误
求高手指点迷津!!多谢帮助!! 展开
2个回答
展开全部
file=open(filename.GetValue(), 'w')
# open() 函数接收两个参数
# 第一个为文件名,绝对路径或相对路径
# 第二个为打扮孙开方式
# 不同参数之间使用 逗号(, ) 分隔
以下是磨陪 open函数源码
def open(name, mode=None, buffering=None): # real signature unknown; restored from __doc__
"""
厅游链 open(name[, mode[, buffering]]) -> file object
Open a file using the file() type, returns a file object. This is the
preferred way to open a file. See file.__doc__ for further information.
"""
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询