PYTHON Ò»¸ö³ÌÐò£¬23ÐÐÓÐ´í£¬²»Ã÷°×Ϊʲô ¾´ÇëÖ¸½Ì£¡
Python code:
class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def paint(self, factory):
point = factory.getPoint()
corner = factory.getCorner()
corner.leftUp()
point.line(self.width - 2)
corner.rightUp()
print()
for i in range(self.height - 2):
point.line(self.width)
print()
corner.leftDown()
point.line(self.width - 2);
corner.rightDown();
print()
class Dot:
def line(self, width):
for i in range(width):
print("-",end="")
class Sharp:
def leftUp(self):
print("#", end="")
def rightUp(self):
print("#", end="")
def leftDown(self):
print("#", end="")
def rightDown(self):
print("#", end="")
class DotSharpFactory:
def getPoint(self):
return Dot()
def getCorner(self):
return Sharp()
rect = Rectangle(20, 10)
rect.paint(DotSharpFactory())
23ÐÐÓÐ´í£¬²»Ã÷°×Ϊʲô ¾´ÇëÖ¸½Ì£¡
Ò²¾ÍÊÇ ÕâÒ»¾ä print("-",end="") Ö¸ÔÚ ¡°£½¡± ÕâÀïÓÐÎÊÌâ
¾õµÃpython 3ÏÂÓ¦¸Ã²»»á´í¡£ÎÒÊÇÓÃ2.6µÄ£¬printµ±º¯ÊýÓÃÒª
Ïà¹ØÎÊ´ð£º
Ïñ C µÄ scanf() ÄÇÑù
±ÈÈç¶ÁÈë 1 2 3 a b c
ÿ´Î¶ÁÈëÒ»¸ö
ÏÂÃæÕâ¸öÓ¦¸ÃÊÇÄãÏëÒªµÄ°É£º
Python code:
>>> k = raw_input()
0 0123 ds dsl sd
>>> k
'0 0123 ds dsl sd'
>>> ......
ËÍƼöÒ»±¾Ñ§Ï°PYTHONµÄÊ飬лл
¡¶python¼òÃ÷½Ì³Ì¡·£¬¡¶pythonºËÐıà³Ì¡·
×÷Ϊϵͳ¹ÜÀí·½Ã棬¡¶Python UNIXºÍLinuxϵͳ¹ÜÀíÖ¸ÄÏ¡·ÊDZ¾·Ç³£²»´íµÄÊé¡£
http://club.book.csdn.net/pic3/255142.jpg
ÒýÓÃ
×÷Î ......
ÔÚÎı¾ÎļþÖÐÆ¥ÅäÏî°üº¬ÖÐÎÄ
ÈçÄÚÈÝΪ£ºgamename=ÖÐÎÄ
key=ÌìÏÂ
Îı¾ÎļþµÄ±àÂëµÄÎļþΪutf-8
python´úÂëÈçÏ£º
# -*- coding:UTF-8 -*-
contents=open(from_pa ......
Python code:
class A:
def __init__(self):
self.B_Handle = B_Handle
self.VA = "A_init"
print "Class A init"
def __getattr__(self, name):
......
ÒÔÏ´úÂëÊÇTk×öÁËÒ»¸ö¼òµ¥µÄÃÜÂëÑéÖ¤¹¦ÄÜ£¬ÊäÈëÒ»¸ö×Ö·û´®£¬²¢ÑéÖ¤ÆäÊÇ·ñÕýÈ·£¬ÇëÏÈ¿´´úÂ룺
Python code:
from tkinter import *
root = Tk()
e = StringVar()
t = 'cashlu'
def yanzheng():
if e ......