Python2学习笔记之gui和安装demjson库

__author__ = 'Administrator'
#coding=utf-8

#python2 Tkinter gui
import Tkinter

def center_window(w=300, h=200):
    # get screen width and height
    ws = root.winfo_screenwidth()
    hs = root.winfo_screenheight()
    # calculate position x, y
    x = (ws/2) - (w/2)
    y = (hs/2) - (h/2)
    root.geometry('%dx%d+%d+%d' % (w, h, x, y))

root=Tkinter.Tk(className='我的第一个python gui')
center_window(500,300)
root.mainloop()
__author__ = 'Administrator'
#coding=utf-8

#python 安装demjson库
'''
$tar xvfz demjson-1.6.tar.gz
$cd demjson-1.6
$python setup.py install
'''
import  demjson
data = [ { 'a' : 1, 'b' : 2, 'c' : 3, 'd' : 4, 'e' : 5 } ]
json=demjson.encode(data)
print(json)

json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
text = demjson.decode(json)
print(text)


你可能感兴趣的:(Python2学习笔记之gui和安装demjson库)