Python论坛  - 讨论区

标题:[python-chinese] 在类中如何使用类里的def?

2006年03月01日 星期三 14:49

Ju Jacky python.plus at gmail.com
Wed Mar 1 14:49:54 HKT 2006

import os
import sys
import cPickle as p

class Note:
 def __int__(self, datafile="iNote.ice"):
  self.datafile = datafile

 def read(self):
  if os.path.isfile(slef.datafile) == False:
   self.puts()

  f = file(self.datafile)
  contents = p.load(f)
  f.close()
  return contents

 def puts(self, contents):
  if os.path.isfile(self.datafile) == False :
   f = file(self.datafile, "w")
   f.writeline(p.dump(["iNoteBook", "Version:0.1", "Author:Jacky"]))
   f.close()
  else:
   f = file(self.datafile, 'a')
   f.writeline(p.dump(contents))
   f.close()
  f = file(self.datafile)
  contents = p.load(f)
  f.close()
  return contents

 def NoteInput(self):
  option = raw_input(r"Select Operation:Read(r), Write(w):")
  if option == "r":
   return self.read()
  elif option == "w":
   name = raw_input("Input Name:")
   age  = raw_input("Input Age:")
   contents = raw_input("Input Contents:")
   return Note.puts([name,age,contents])
if __name__ == "__main__":
 inote = Note()
 print inote.NoteInput()

我怎么都运行不了. 也不知道如何在类中使用类里的函数, 请DX们指点一下. 我新人,别笑我. 谢谢! :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060301/88ac73ac/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 15:25

Ju Jacky python.plus at gmail.com
Wed Mar 1 15:25:04 HKT 2006

import os
import sys
import cPickle as p

class Note:
 def __int__(self, datafile="iNote.ice"):
  self.datafile = datafile

 def read(self):
  if os.path.isfile(slef.datafile) == False:
   self.puts()

  f = file(self.datafile)
  contents = p.load(f)
  f.close()
  return contents

 def puts(self, contents):
  if os.path.isfile(self.datafile) == False :
   f = file(self.datafile, "w")
   f.writeline(p.dump(["iNoteBook", "Version:0.1", "Author:Jacky"]))
   f.close()
  else:
   f = file(self.datafile, 'a')
   f.writeline(p.dump(contents))
   f.close()
  f = file( self.datafile)
  contents = p.load(f)
  f.close()
  return contents

 def NoteInput(self):
  option = raw_input(r"Select Operation:Read(r), Write(w):")
  if option == "r":
   return self.read()
  elif option == "w":
   name = raw_input("Input Name:")
   age  = raw_input("Input Age:")
   contents = raw_input("Input Contents:")
   return Note.puts([name,age,contents])
if __name__ == "__main__":
 inote = Note()
 print inote.NoteInput()

我怎么都运行不了. 也不知道如何在类中使用类里的函数, 请DX们指点一下. 我新人,别笑我. 谢谢! :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060301/4a8942ce/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 18:14

makeyunbad makeyunbad at gmail.com
Wed Mar 1 18:14:13 HKT 2006

在 06-3-1,Ju Jacky<python.plus at gmail.com> 写道:
> 我怎么都运行不了. 也不知道如何在类中使用类里的函数, 请DX们指点一下. 我新人,别笑我. 谢谢! :)
> _______________________________________________


>>> class foo:
... 	def a(self):
... 		print 'a'
... 	def b(self):
... 		self.a()
... 		
>>> ok = foo()
>>> ok.b()
a

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 18:22

makeyunbad makeyunbad at gmail.com
Wed Mar 1 18:22:33 HKT 2006

在 06-3-1,Ju Jacky<python.plus at gmail.com> 写道:
>
>
> import os
> import sys
> import cPickle as p
>
> class Note:
>  def __int__(self, datafile="iNote.ice"):
>   self.datafile = datafile
>
>  def read(self):
>   if os.path.isfile(slef.datafile) == False:
>    self.puts()
>
>   f = file(self.datafile)
>   contents = p.load(f)
>   f.close()
>   return contents
>
>  def puts(self, contents):
>   if os.path.isfile(self.datafile) == False :
>    f = file(self.datafile, "w")
>    f.writeline(p.dump(["iNoteBook", "Version:0.1", "Author:Jacky"]))
>    f.close()
>   else:
>    f = file(self.datafile, 'a')
>    f.writeline(p.dump(contents))
>    f.close()
>   f = file( self.datafile)
>   contents = p.load(f)
>   f.close()
>   return contents
>
>  def NoteInput(self):
>   option = raw_input(r"Select Operation:Read(r), Write(w):")
>   if option == "r":
>    return self.read()
>   elif option == "w":
>    name = raw_input("Input Name:")
>    age  = raw_input("Input Age:")
>    contents = raw_input("Input Contents:")
>    return Note.puts([name,age,contents])

这句不对吧,return self.puts([name,age,contents])

> if __name__ == "__main__":
>  inote = Note()
>  print inote.NoteInput()
>
> 我怎么都运行不了. 也不知道如何在类中使用类里的函数, 请DX们指点一下. 我新人,别笑我. 谢谢! :)
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 19:37

tcgy2004 tcgy2004 at tom.com
Wed Mar 1 19:37:38 HKT 2006

你好!

另外,dump函数有两个参数,为什么你只给一个参数?
更改了部分错误
import os
import sys
import cPickle as p

class Note:
 def __init__(self, datafile="iNote.ice"): #change point
  self.datafile = datafile
  print "hello"
  
 def read(self):
  if os.path.isfile(self.datafile) == False:
   self.puts()

  f = file(self.datafile)
  contents = p.load(f)
  f.close()
  return contents
  
 def puts(self, contents):
  if os.path.isfile(self.datafile) == False :
   f = file(self.datafile, "w") 
   f.writelines(p.dump(["iNoteBook", "Version:0.1", "Author:Jacky"])) #change point
   f.close()
   
  else:
   f = file(self.datafile, 'a') 
   f.writelines(p.dump(contents))  #change point

   f.close()
  f = file( self.datafile)
  contents = p.load(f)
  f.close()
  return contents

 def NoteInput(self):
  option = raw_input(r"Select Operation:Read(r), Write(w):")
  if option == "r":
   return self.read()
  elif option == "w":
   name = raw_input("Input Name:") 
   age  = raw_input("Input Age:")
   contents = raw_input("Input Contents:")
   return self.puts([name,age,contents])   #change point

if __name__ == "__main__":
 inote = Note()
 print inote.NoteInput()


  ----- Original Message ----- 
  From: Ju Jacky 
  To: python-chinese at lists.python.cn 
  Sent: Wednesday, March 01, 2006 3:25 PM
  Subject: [python-chinese] 在类中如何使用类里的def?


  import os
  import sys
  import cPickle as p

  class Note:
   def __int__(self, datafile="iNote.ice"):
    self.datafile = datafile
    
   def read(self):
    if os.path.isfile(slef.datafile) == False:
     self.puts()

    f = file(self.datafile)
    contents = p.load(f)
    f.close()
    return contents
    
   def puts(self, contents):
    if os.path.isfile(self.datafile) == False :
     f = file(self.datafile, "w") 
     f.writeline(p.dump(["iNoteBook", "Version:0.1", "Author:Jacky"]))
     f.close()
    else:
     f = file(self.datafile, 'a')
     f.writeline(p.dump(contents))
     f.close()
    f = file( self.datafile)
    contents = p.load(f)
    f.close()
    return contents

   def NoteInput(self):
    option = raw_input(r"Select Operation:Read(r), Write(w):")
    if option == "r":
     return self.read()
    elif option == "w":
     name = raw_input("Input Name:") 
     age  = raw_input("Input Age:")
     contents = raw_input("Input Contents:")
     return Note.puts([name,age,contents])

  if __name__ == "__main__":
   inote = Note()
   print inote.NoteInput()

  我怎么都运行不了. 也不知道如何在类中使用类里的函数, 请DX们指点一下. 我新人,别笑我. 谢谢! :)


------------------------------------------------------------------------------


  _______________________________________________
  python-chinese
  Post: send python-chinese at lists.python.cn
  Subscribe: send subscribe to python-chinese-request at lists.python.cn
  Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
  Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060301/b089e8c6/attachment-0001.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 21:00

Ju Jacky python.plus at gmail.com
Wed Mar 1 21:00:36 HKT 2006

我在线等了好久. 没有帮我. 我自己琢磨. 呵呵.  昨天晚上开始学python. 今天就试着写. 所以...:)

现在我把进度加到了sqlite中了.

问个问题, 我要怎么处理 图形介面呢?

[code]

#-*-coding:gb2312-*-
#
import os
import sys
import time
from pysqlite2 import dbapi2 as sqlite

class Note:

 dbname = "iNote.ice"

 def __init__(self, dbname="iNote.ice"):
  self.dbname = dbname
  local_db = self.dbname
  if os.path.isfile(local_db) == False :
   con = sqlite.connect(self.dbname, isolation_level=None)
   createSql = """
    CREATE TABLE iceNote(
     id INTEGER PRIMARY KEY,
     name VARCHAR(255),
     age  VARCHAR(255),
     sex  VARCHAR(2),
     work VARCHAR(255),
     addr VARCHAR(255),
     mobile1 VARCHAR(255),
     mobile2 VARCHAR(255),
     mobile3 VARCHAR(255),
     tel1 VARCHAR(255),
     tel2 VARCHAR(255),
     tel3 VARCHAR(255),
     addtime VARCHAR(13),
     edittime VARCHAR(13)
    );"""
   con.execute(createSql);
   con.execute(u'INSERT INTO iceNote VALUES (null, "姓名",
"年龄","性别","工作","地址","手提1","手提2","手提3","电话1","电话2","电话3","添加日期","修改日期")')
   con.close()

  self.con = sqlite.connect(self.dbname, isolation_level=None)

 def rf(self):
  cur = self.con.cursor()
  cur.execute("SELECT * FROM iceNote")

  print """
  ***************************************
  **         数据库记录读出             *
  ***************************************"""
  print
"-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-";
  for (id, name,
age,sex,work,addr,mobile1,mobile2,mobile3,tel1,tel2,tel3,addtime,edittime)
in cur:
   print (u'序列号: %s \n姓名: %s  \n年龄: %s \n性别: %s \n工作: %s \n地址: %s \n手提1: %s
\n手提2: %s \n手提3: %s \n电话1: %s \n电话2: %s \n电话3: %s \n创建日期: %s \n最手修改日期: %s')
% (id, name,
age,sex,work,addr,mobile1,mobile2,mobile3,tel1,tel2,tel3,addtime,edittime)
   print
"-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-";
  print "\n所有记录都已读出.";

 def puts(self, txt):
  self.con.execute(txt)
  return txt

 def NoteInput(self):
  option = raw_input(r"请选择操:读取(r),写入(w), 退出(q):")
  selfloop = True
  while selfloop:
   if option == "r":
    self.rf()
    self.NoteInput()
   elif option == "w":
    name = raw_input("姓名")
    age = raw_input("年龄")
    sex = raw_input("性别")
    work = raw_input("工作")
    addr = raw_input("地址")
    mobile1 = raw_input("手提1")
    mobile2 = raw_input("手提2")
    mobile3 = raw_input("手提3")
    tel1 = raw_input("电话1")
    tel2 = raw_input("电话2")
    tel3 = raw_input("电话3")
    t = time.strftime('%Y-%m-%d %H:%M:%S')
    sql = u'INSERT INTO iceNote VALUES (null, "%s",
"%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s")' % (name,
age,sex,work,addr,mobile1,mobile2,mobile3,tel1,tel2,tel3,t,t)
    self.puts(sql)
    print "数据已录入\n"
    self.NoteInput();
   elif option == "q":
    print """
    *---------------------------*
    * 谢谢你的使用,再见!        *
    *---------------------------*"""
    self.con.close()
    selfloop = False
    sys.exit()
    break
   else:
    print """
    *---------------------------*
    * 你想要做什么?请告诉我.    *
    *---------------------------*"""
    self.NoteInput()

def main():
 iNotef = Note()
 iNotef.NoteInput()

if __name__ == "__main__":
    main()
[/code]


在06-3-1,tcgy2004 <tcgy2004 at tom.com> 写道:
>
> 你好!
>
> 另外,dump函数有两个参数,为什么你只给一个参数?
> 更改了部分错误
> import os
> import sys
> import cPickle as p
>
> class Note:
>  def __init__(self, datafile="iNote.ice"): #change point
>   self.datafile = datafile
>   print "hello"
>
>  def read(self):
>   if os.path.isfile(self.datafile) == False:
>    self.puts()
>
>   f = file(self.datafile)
>   contents = p.load(f)
>   f.close()
>   return contents
>
>  def puts(self, contents):
>   if os.path.isfile(self.datafile) == False :
>    f = file(self.datafile, "w")
>    f.writelines(p.dump(["iNoteBook", "Version:0.1", "Author:Jacky"]))
> #change point
>    f.close()
>
>   else:
>    f = file(self.datafile, 'a')
>    f.writelines(p.dump(contents))  #change point
>
>    f.close()
>   f = file( self.datafile)
>   contents = p.load(f)
>   f.close()
>   return contents
>
>  def NoteInput(self):
>   option = raw_input(r"Select Operation:Read(r), Write(w):")
>   if option == "r":
>    return self.read()
>   elif option == "w":
>    name = raw_input("Input Name:")
>    age  = raw_input("Input Age:")
>    contents = raw_input("Input Contents:")
>    return self.puts([name,age,contents])   #change point
>
> if __name__ == "__main__":
>  inote = Note()
>  print inote.NoteInput()
>
>  ----- Original Message -----
> *From:* Ju Jacky <python.plus at gmail.com>
> *To:* python-chinese at lists.python.cn
> *Sent:* Wednesday, March 01, 2006 3:25 PM
> *Subject:* [python-chinese] 在类中如何使用类里的def?
>
>
>
> import os
> import sys
> import cPickle as p
>
> class Note:
>  def __int__(self, datafile="iNote.ice"):
>   self.datafile = datafile
>
>  def read(self):
>   if os.path.isfile(slef.datafile) == False:
>    self.puts()
>
>   f = file(self.datafile)
>   contents = p.load(f)
>   f.close()
>   return contents
>
>  def puts(self, contents):
>   if os.path.isfile(self.datafile) == False :
>    f = file(self.datafile, "w")
>    f.writeline(p.dump(["iNoteBook", "Version:0.1", "Author:Jacky"]))
>    f.close()
>   else:
>    f = file(self.datafile, 'a')
>    f.writeline(p.dump(contents))
>    f.close()
>   f = file( self.datafile)
>   contents = p.load(f)
>   f.close()
>   return contents
>
>  def NoteInput(self):
>   option = raw_input(r"Select Operation:Read(r), Write(w):")
>   if option == "r":
>    return self.read()
>   elif option == "w":
>    name = raw_input("Input Name:")
>    age  = raw_input("Input Age:")
>    contents = raw_input("Input Contents:")
>    return Note.puts([name,age,contents])
> if __name__ == "__main__":
>  inote = Note()
>  print inote.NoteInput()
>
> 我怎么都运行不了. 也不知道如何在类中使用类里的函数, 请DX们指点一下. 我新人,别笑我. 谢谢! :)
>
> ------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060301/ad4739c9/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 21:01

Ju Jacky python.plus at gmail.com
Wed Mar 1 21:01:53 HKT 2006

这个现在只能在终端运行. python默认是Tk,那我样怎么用Tk进行GUI处理 呢?
程序是可以运行了.


在06-3-1,Ju Jacky <python.plus at gmail.com> 写道:
>
> 我在线等了好久. 没有帮我. 我自己琢磨. 呵呵.  昨天晚上开始学python. 今天就试着写. 所以...:)
>
> 现在我把进度加到了sqlite中了.
>
> 问个问题, 我要怎么处理 图形介面呢?
>
> [code]
>
> #-*-coding:gb2312-*-
> #
> import os
> import sys
> import time
> from pysqlite2 import dbapi2 as sqlite
>
> class Note:
>
>  dbname = "iNote.ice"
>
>  def __init__(self, dbname="iNote.ice"):
>   self.dbname = dbname
>   local_db = self.dbname
>   if os.path.isfile(local_db) == False :
>    con = sqlite.connect(self.dbname, isolation_level=None)
>    createSql = """
>     CREATE TABLE iceNote(
>      id INTEGER PRIMARY KEY,
>      name VARCHAR(255),
>      age  VARCHAR(255),
>      sex  VARCHAR(2),
>      work VARCHAR(255),
>      addr VARCHAR(255),
>      mobile1 VARCHAR(255),
>      mobile2 VARCHAR(255),
>      mobile3 VARCHAR(255),
>      tel1 VARCHAR(255),
>      tel2 VARCHAR(255),
>      tel3 VARCHAR(255),
>      addtime VARCHAR(13),
>      edittime VARCHAR(13)
>     );"""
>    con.execute(createSql);
>    con.execute(u'INSERT INTO iceNote VALUES (null, "姓名",
> "年龄","性别","工作","地址","手提1","手提2","手提3","电话1","电话2","电话3","添加日期","修改日期")')
>    con.close()
>
>   self.con = sqlite.connect(self.dbname, isolation_level=None)
>
>  def rf(self):
>   cur = self.con.cursor()
>   cur.execute("SELECT * FROM iceNote")
>
>   print """
>   ***************************************
>   **         数据库记录读出             *
>   ***************************************"""
>   print
> "-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-";
>
>   for (id, name,
> age,sex,work,addr,mobile1,mobile2,mobile3,tel1,tel2,tel3,addtime,edittime)
> in cur:
>    print (u'序列号: %s \n姓名: %s  \n年龄: %s \n性别: %s \n工作: %s \n地址: %s \n手提1:
> %s \n手提2: %s \n手提3: %s \n电话1: %s \n电话2: %s \n电话3: %s \n创建日期: %s \n最手修改日期:
> %s') % (id, name,
> age,sex,work,addr,mobile1,mobile2,mobile3,tel1,tel2,tel3,addtime,edittime)
>    print
> "-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-";
>   print "\n所有记录都已读出.";
>
>  def puts(self, txt):
>   self.con.execute(txt)
>   return txt
>
>  def NoteInput(self):
>   option = raw_input(r"请选择操:读取(r),写入(w), 退出(q):")
>   selfloop = True
>   while selfloop:
>    if option == "r":
>     self.rf()
>     self.NoteInput()
>    elif option == "w":
>     name = raw_input("姓名")
>     age = raw_input("年龄")
>     sex = raw_input("性别")
>     work = raw_input("工作")
>     addr = raw_input("地址")
>     mobile1 = raw_input("手提1")
>     mobile2 = raw_input("手提2")
>     mobile3 = raw_input("手提3")
>     tel1 = raw_input("电话1")
>     tel2 = raw_input("电话2")
>     tel3 = raw_input("电话3")
>     t = time.strftime('%Y-%m-%d %H:%M:%S')
>     sql = u'INSERT INTO iceNote VALUES (null, "%s",
> "%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s")' % (name,
> age,sex,work,addr,mobile1,mobile2,mobile3,tel1,tel2,tel3,t,t)
>     self.puts(sql)
>     print "数据已录入\n"
>     self.NoteInput();
>    elif option == "q":
>     print """
>     *---------------------------*
>     * 谢谢你的使用,再见!        *
>     *---------------------------*"""
>     self.con.close()
>     selfloop = False
>     sys.exit()
>     break
>    else:
>     print """
>     *---------------------------*
>     * 你想要做什么?请告诉我.    *
>     *---------------------------*"""
>     self.NoteInput()
>
> def main():
>  iNotef = Note()
>  iNotef.NoteInput()
>
> if __name__ == "__main__":
>     main()
> [/code]
>
>
> 在06-3-1,tcgy2004 <tcgy2004 at tom.com> 写道:
> >
> > 你好!
> >
> > 另外,dump函数有两个参数,为什么你只给一个参数?
> > 更改了部分错误
> > import os
> > import sys
> > import cPickle as p
> >
> > class Note:
> >  def __init__(self, datafile="iNote.ice"): #change point
> >   self.datafile = datafile
> >   print "hello"
> >
> >  def read(self):
> >   if os.path.isfile(self.datafile ) == False:
> >    self.puts()
> >
> >   f = file(self.datafile)
> >   contents = p.load(f)
> >   f.close()
> >   return contents
> >
> >  def puts(self, contents):
> >   if os.path.isfile(self.datafile) == False :
> >    f = file( self.datafile, "w")
> >    f.writelines(p.dump(["iNoteBook", "Version:0.1", "Author:Jacky"]))
> > #change point
> >    f.close()
> >
> >   else:
> >    f = file(self.datafile , 'a')
> >    f.writelines(p.dump(contents))  #change point
> >
> >    f.close()
> >   f = file( self.datafile)
> >   contents = p.load(f)
> >   f.close()
> >   return contents
> >
> >  def NoteInput(self):
> >   option = raw_input(r"Select Operation:Read(r), Write(w):")
> >   if option == "r":
> >    return self.read()
> >   elif option == "w":
> >    name = raw_input("Input Name:")
> >    age  = raw_input("Input Age:")
> >    contents = raw_input("Input Contents:")
> >    return self.puts([name,age,contents])   #change point
> >
> > if __name__ == "__main__":
> >  inote = Note()
> >  print inote.NoteInput()
> >
> >  ----- Original Message -----
> > *From:* Ju Jacky <python.plus at gmail.com>
> > *To:* python-chinese at lists.python.cn
> > *Sent:* Wednesday, March 01, 2006 3:25 PM
> > *Subject:* [python-chinese] 在类中如何使用类里的def?
> >
> >
> >
> > import os
> > import sys
> > import cPickle as p
> >
> > class Note:
> >  def __int__(self, datafile="iNote.ice"):
> >   self.datafile = datafile
> >
> >  def read(self):
> >   if os.path.isfile(slef.datafile) == False:
> >    self.puts()
> >
> >   f = file(self.datafile)
> >   contents = p.load(f)
> >   f.close()
> >   return contents
> >
> >  def puts(self, contents):
> >   if os.path.isfile(self.datafile) == False :
> >    f = file(self.datafile, "w")
> >    f.writeline(p.dump(["iNoteBook", "Version:0.1", "Author:Jacky"]))
> >    f.close()
> >   else:
> >    f = file(self.datafile, 'a')
> >    f.writeline(p.dump(contents))
> >    f.close()
> >   f = file( self.datafile)
> >   contents = p.load(f)
> >   f.close()
> >   return contents
> >
> >  def NoteInput(self):
> >   option = raw_input(r"Select Operation:Read(r), Write(w):")
> >   if option == "r":
> >    return self.read()
> >   elif option == "w":
> >    name = raw_input("Input Name:")
> >    age  = raw_input("Input Age:")
> >    contents = raw_input("Input Contents:")
> >    return Note.puts([name,age,contents])
> > if __name__ == "__main__":
> >  inote = Note()
> >  print inote.NoteInput()
> >
> > 我怎么都运行不了. 也不知道如何在类中使用类里的函数, 请DX们指点一下. 我新人,别笑我. 谢谢! :)
> >
> > ------------------------------
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060301/9ad15a2d/attachment-0001.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 21:06

limodou limodou at gmail.com
Wed Mar 1 21:06:04 HKT 2006

On 3/1/06, Ju Jacky <python.plus at gmail.com> wrote:
>
> 我在线等了好久. 没有帮我. 我自己琢磨. 呵呵.  昨天晚上开始学python. 今天就试着写. 所以...:)
>
> 现在我把进度加到了sqlite中了.
>
> 问个问题, 我要怎么处理 图形介面呢?
>

不是已经有人回答你了吗?是你没回啊.加入图形要学习相关的图形库的知识,如tk(python自带), wxPython, pygtk,
pyqt等.tk要自已去找材料了.


--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 21:11

Ju Jacky python.plus at gmail.com
Wed Mar 1 21:11:39 HKT 2006

相对来说, 那个好用(使用方便)一些呢?

有没有python的交流点呀. 如什么QQ群之类的或高手的QQ之类的呀.


在06-3-1,limodou <limodou at gmail.com> 写道:
>
> On 3/1/06, Ju Jacky <python.plus at gmail.com> wrote:
> >
> > 我在线等了好久. 没有帮我. 我自己琢磨. 呵呵.  昨天晚上开始学python. 今天就试着写. 所以...:)
> >
> > 现在我把进度加到了sqlite中了.
> >
> > 问个问题, 我要怎么处理 图形介面呢?
> >
>
> 不是已经有人回答你了吗?是你没回啊.加入图形要学习相关的图形库的知识,如tk(python自带), wxPython, pygtk,
> pyqt等.tk要自已去找材料了.
>
>
> --
> I like python!
> My Blog: http://www.donews.net/limodou
> NewEdit Maillist: http://groups.google.com/group/NewEdit
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060301/052a1f15/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 21:16

limodou limodou at gmail.com
Wed Mar 1 21:16:17 HKT 2006

On 3/1/06, Ju Jacky <python.plus at gmail.com> wrote:
>
> 相对来说, 那个好用(使用方便)一些呢?
>
还要看个人的熟练程度.建议你学习wxPython.

> 有没有python的交流点呀. 如什么QQ群之类的或高手的QQ之类的呀.
>
还是先学习吧.这里不方便吗?有一定基础之后再问人比较好.要学会使用google.


--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 21:24

Ju Jacky python.plus at gmail.com
Wed Mar 1 21:24:57 HKT 2006

wxPython 下载中.  谢了. limodou, python的确是非常的简单. 就是那个activepython的IDE真的是很水.

加问一点, utf-8要怎么做?
#-*-coding:gb2312-*-
这个对中文是支持了.
换成utf-8, 再把文件保存成utf-8nobom格式 字符加u还是错误. google了. 还是不太明白.


在06-3-1,limodou <limodou at gmail.com> 写道:
>
> On 3/1/06, Ju Jacky <python.plus at gmail.com> wrote:
> >
> > 相对来说, 那个好用(使用方便)一些呢?
> >
> 还要看个人的熟练程度.建议你学习wxPython.
>
> > 有没有python的交流点呀. 如什么QQ群之类的或高手的QQ之类的呀.
> >
> 还是先学习吧.这里不方便吗?有一定基础之后再问人比较好.要学会使用google.
>
>
> --
> I like python!
> My Blog: http://www.donews.net/limodou
> NewEdit Maillist: http://groups.google.com/group/NewEdit
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060301/13420f02/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 21:25

Ju Jacky python.plus at gmail.com
Wed Mar 1 21:25:55 HKT 2006

http://prdownloads.sourceforge.net/wxpython/wxPython2.6-win32-unicode-2.6.2.1-py24.exe

惨了, sf上不去.  晕死了.


在06-3-1,Ju Jacky <python.plus at gmail.com> 写道:
>
> wxPython 下载中.  谢了. limodou, python的确是非常的简单. 就是那个activepython的IDE真的是很水.
>
> 加问一点, utf-8要怎么做?
> #-*-coding:gb2312-*-
> 这个对中文是支持了.
> 换成utf-8, 再把文件保存成utf-8nobom格式 字符加u还是错误. google了. 还是不太明白.
>
>
> 在06-3-1,limodou <limodou at gmail.com> 写道:
> >
> > On 3/1/06, Ju Jacky <python.plus at gmail.com> wrote:
> > >
> > > 相对来说, 那个好用(使用方便)一些呢?
> > >
> > 还要看个人的熟练程度.建议你学习wxPython.
> >
> > > 有没有python的交流点呀. 如什么QQ群之类的或高手的QQ之类的呀.
> > >
> > 还是先学习吧.这里不方便吗?有一定基础之后再问人比较好.要学会使用google.
> >
> >
> > --
> > I like python!
> > My Blog: http://www.donews.net/limodou
> > NewEdit Maillist: http://groups.google.com/group/NewEdit
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060301/6e6a7acf/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 22:01

limodou limodou at gmail.com
Wed Mar 1 22:01:46 HKT 2006

On 3/1/06, Ju Jacky <python.plus at gmail.com> wrote:
>
> wxPython 下载中.  谢了. limodou, python的确是非常的简单. 就是那个activepython的IDE真的是很水.
>
> 加问一点, utf-8要怎么做?
> #-*-coding:gb2312-*-
> 这个对中文是支持了.
> 换成utf-8, 再把文件保存成utf-8nobom格式 字符加u还是错误. google了. 还是不太明白.
>

#coding=utf-8

a = '中文'  #这是一个utf-8的字符串
a = u'中文' #这是一个unicode

整个文件需要存为utf-8编码.


--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月01日 星期三 22:13

Ju Jacky python.plus at gmail.com
Wed Mar 1 22:13:27 HKT 2006

原来python中的unicode和utf-8不是一回事呀. 我理解错了. 呵呵. OK. 现在明白了.

在06-3-1,limodou <limodou at gmail.com> 写道:
>
> On 3/1/06, Ju Jacky <python.plus at gmail.com> wrote:
> >
> > wxPython 下载中.  谢了. limodou, python的确是非常的简单. 就是那个activepython的IDE真的是很水.
> >
> > 加问一点, utf-8要怎么做?
> > #-*-coding:gb2312-*-
> > 这个对中文是支持了.
> > 换成utf-8, 再把文件保存成utf-8nobom格式 字符加u还是错误. google了. 还是不太明白.
> >
>
> #coding=utf-8
>
> a = '中文'  #这是一个utf-8的字符串
> a = u'中文' #这是一个unicode
>
> 整个文件需要存为utf-8编码.
>
>
> --
> I like python!
> My Blog: http://www.donews.net/limodou
> NewEdit Maillist: http://groups.google.com/group/NewEdit
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060301/3af12e77/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年03月02日 星期四 20:06

tim bkkkd at 163.com
Thu Mar 2 20:06:25 HKT 2006

QQ对于不想动脑根的是很好的
----- Original Message ----- 
From: "limodou" <limodou at gmail.com>
To: <python-chinese at lists.python.cn>
Sent: Wednesday, March 01, 2006 9:16 PM
Subject: Re: [python-chinese] 在类中如何使用类里的def?


> On 3/1/06, Ju Jacky <python.plus at gmail.com> wrote:
>>
>> 相对来说, 那个好用(使用方便)一些呢?
>>
> 还要看个人的熟练程度.建议你学习wxPython.
> 
>> 有没有python的交流点呀. 如什么QQ群之类的或高手的QQ之类的呀.
>>
> 还是先学习吧.这里不方便吗?有一定基础之后再问人比较好.要学会使用google.
> 
> 
> --
> I like python!
> My Blog: http://www.donews.net/limodou
> NewEdit Maillist: http://groups.google.com/group/NewEdit
>


--------------------------------------------------------------------------------


> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号