# -*- coding: mbcs -*-
from Tkinter import *
class Application(Frame):
def say_i(self):
print "hi there, every oe!"
def createWidgets(self):
self.QUIT = Button(self)
self.QUIT["text"] = "QUIT"
self.QUIT["fg"] = "red"
self.QUIT["command"] = self.quit
self.QUIT.pack({"side": "left"})
self.hi_there = Button(self)
self.hi_there["text"] = "안녕~~",
print self.hi_there["text"]
self.hi_there["command"] = self.say_i
self.hi_there.pack({"side": "left"})
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
app = Application()
app.master.title("Zelon's Dialog")
app.mainloop()
pystr = "Python" print pystr[2:5] 'tho' print pystr[:2] 'Py' print pystr[3:] 'hon' print pystr[-1] 'n'
enc = unicode(s, "utf-8", "ignore").encode("cp949")
| keys() | 키들을 리턴 |
| values() | 값들을 리턴 |
| items() | (키,값) 리스트 리턴 |
| key in D | D 가 key 를 가지면 True 리턴 |
| clear() | 모든 아이템 제거 |
for item in items:
print item
for eachnum in range(6)
print eachnum
0
1
2
3
4
5
try:
try_suite
except somError:
except_suite
== 함수 ==
{{{
def functionname(arg ... ):
return somevalue
class FooClass:
version = 0.1
def __init(self):
# 'constructor'
self.name = "Kimjinwook"
def showname(self)
print self.name
import zipfile
aZip = zipfile.ZipFile("newzrchive.zip", "w")
aZip.write("test1.txt")
aZip.write("sub/test2.txt")
aZip.close()
print "Kim " , print "Jinwook"
print "%s is number %d" % ("Zelon", 3)
import urllib
f = urllib.urlopen("http://wimy.com")
print f.headers
print f.read()
from httplib import HTTP
cookie = "PHPSESSID=2fffeefefef22fefefe"
request = HTTP("wimy.com")
request.putrequest("GET", "/")
request.putheader("Accept", "text/html")
request.putheader("UserAgent", "PythonAgent")
request.putheader("Host", "wimy.com")
request.putheader("Cookie", cookie)
request.endheaders()
import sys print sys.argv print sys.argv[0] # a.py print sys.argv[1] # 첫번째 인자