# _*_coding:utf-8_*_

from os.path import exists
from sys import exit
import time
import Tkinter

def main():
    global win
    win = Tkinter.Tk()
    # 为窗体设置标题和大小
    win.title = ('Picklecai notebook')
    win.geography = ('640x480')
    # 放置三个按钮供选择
    b1 = Tkinter.Button(win, text="打印历史记录", command=printhistory)
    b2 = Tkinter.Button(win, text="输入新的内容", command=writenew)
    b3 = Tkinter.Button(win, text="退出程序", command=exit1)
    b1.grid(row=0, column=0)
    b2.grid(row=0, column=2)
    b3.grid(row=0, column=4)
    win.mainloop()

def printhistory():
    # 打印之前所有的内容
    historyfirst = '''
    历史记录：
    -------------------------------------------''' + "\n"
    historynone = "对不起，程序第一次运行，尚无历史记录可打印。你可以开始输入新内容。"
    l1 = Tkinter.Label(win)
    if exists("tempfile.txt"):   # 如果tempfile不存在，说明程序是第一次运行，没有历史内容可打印。
        txt = open("tempfile.txt")
        notelist = txt.readlines()
        txt.close()
        for i in notelist:
            historyfirst += (i + "\n")
        historyfirst += ("\n" + "-------------------------------------------")
        l1.configure(text=historyfirst)
    else:
        l1.configure(text=historynone)
    l1.grid(row=1, column=0)

def writenew():
    # 输入新的内容
    prompt = "今日记录，请输入： "
    l3 = Tkinter.Label(win, text=prompt)
    l3.grid(row=1, column=2)
    newline = Tkinter.Entry(win)
    newline.grid(row=2, column=2)

    def savenew():
        # 保存
        fn = Tkinter.Entry(win)
        fn.grid(row=4, column=2)
        if fn.bind('<Key-Return>'):
            filename = fn.get().encode("utf-8")
            # filename = raw_input("Input your filename: ")
            output = open(filename + ".txt", 'w')  # 规定好扩展名，以免出现用户保存的文件打不开的情况。
            output.write(filename + ".txt"+"\n")  # 在文件中写入文件名。
            output.write(time.strftime("%d/%m/%Y %H:%M:%S"+"\n"))  # 写入当前时间。
            output.write(newline.get().encode("utf-8"))  # 可以输入汉字
            output = open(filename + ".txt")
            output.close
        # 暂存
        txt = open("tempfile.txt", 'a')
        txt.write(time.strftime("%d/%m/%Y %H:%M:%S"+"\n"))  # 在保存当前输入时，也保存当前时间。
        txt.write(newline.get().encode("utf-8"))  # 可以输入汉字
        txt.write("\n"+"\n")
        txt.close()

    b4 = Tkinter.Button(win, text="保存新内容", command=savenew)
    b4.grid(row=3, column=2)

def exit1():
    exit()

if __name__ == '__main__':
    main()

@@ -1522,19 +1522,16 @@
         
-if 
 fn.bind(
@@ -1548,58 +1548,15 @@
 rn%3E'
-):%0D%0A            filename = fn.get().encode(%22utf-8%22
+, fuzhi
 )%0D%0A 
@@ -1561,22 +1561,16 @@
 %0A       
-     #
  filenam
@@ -1577,48 +1577,19 @@
 e = 
-raw_input(%22Input your filename: %22)%0D%0A    
+fuzhi(fn)%0D%0A
     
@@ -1660,36 +1660,32 @@
 %E4%B8%8D%E5%BC%80%E7%9A%84%E6%83%85%E5%86%B5%E3%80%82%0D%0A        
-    
 output.write(fil
@@ -1720,36 +1720,32 @@
 %E5%86%99%E5%85%A5%E6%96%87%E4%BB%B6%E5%90%8D%E3%80%82%0D%0A        
-  
-  
 output.write(tim
@@ -1798,28 +1798,24 @@
 %E9%97%B4%E3%80%82%0D%0A        
-    
 output.write
@@ -1861,28 +1861,24 @@
 %E6%B1%89%E5%AD%97%0D%0A        
- 
-   
 output = ope
@@ -1895,28 +1895,24 @@
  + %22.txt%22)%0D%0A
-    
         outp
@@ -2227,24 +2227,24 @@
 d=savenew)%0D%0A
-
     b4.grid(
@@ -2259,24 +2259,116 @@
 olumn=2)%0D%0A%0D%0A
+def fuzhi(e):%0D%0A    e = Tkinter.Entry(win)%0D%0A    f = e.get().encode(%22utf-8%22)%0D%0A    return f%0D%0A%0D%0A
 def exit1():

Update main.py