beginning python summary chapter 3 ʹÓÃ×Ö·û´®
0¡¢×Ö·û´®ÊDz»¿É±äµÄ¡£
1¡¢»ù±¾×Ö·û´®²Ù×÷£ºË÷Òý¡¢ÇÐƬ¡¢¸´ÖÆ¡¢³ÉÔ±¡¢³¤¶È¡¢×î´óºÍ×îС¡£
2¡¢×Ö·û´®¸ñʽ»¯£ºÓøñʽ»¯²Ù×÷·û°Ù·ÖºÅ%ʵÏÖ£¬eg:>>> format = "Hello, %s. %s enough for ya?"
>>> values = ('world', 'Hot') //Ôª×é
>>> print format % values
values ¿ÉÒÔÊǵ¥¶ÀµÄÖµ£¬±ÈÈç×Ö·û´®»òÊý×Ö£»Ò²¿ÉÒÔÊǶà¸öÖµ£¬±ÈÈçÔª×é¡£
ÒªÔÚ¸ñʽ»¯×Ö·û´®ÀïÃæ°üÀ¨°Ù·ÖºÅ£¬ ÄãÓ¦¸ÃʹÓÃ%%¡£
Èç¹ûÄã¸ñʽ»¯ÊµÊý£¨¸¡µãÊý£© µÄ»°£¬¿ÉÒÔʹÓÃfÕâ¸ö˵Ã÷ÀàÐÍ£¬¼ÓÉÏ×÷Ϊ¾«¶ÈµÄµãºÅ“.”£¬ºóÃæ¸úÉÏÄãÏ£Íû±£ÁôµØСÊýλÊýµÄÊ®½øÖÆ¡£eg:>>> format = "Pi with three decimals: %.3f"
>>> from math import pi
>>> print format % pi
3¡¢Ä£°å×Ö·û´®£ºstringÄ£¿éÌṩÁíÍâÒ»ÖÖ¸ñʽ»¯ÖµµÄ·½·¨£ºÄ£°å×Ö·û´®¡£ËüµÄ¹¤×÷·½Ê½ÀàËÆÓںܶàUNIXShellÀïµÄ±äÁ¿Ìæ»»£¬Ê¹Óô«µÝµ½substitute·½·¨µÄfooµÄ¹Ø¼ü×Ö²ÎÊýÌæ»»$foo£º
>>> from string import Template
>>> s = Template('$x, glorious $x!')
>>> s.substitute(x='slurm')
'slurm, glorious slurm!'
Èç¹ûÌæ»
Ïà¹ØÎĵµ£º
×î½üÏÂÔØÁËÒ»·Ý×îеÄpython3.0Íæ¶ù
ûÏëµ½print(Hello world)¾ÍÄÑΪÁËÎÒ°ëÌì
ÎÊÌâ1£¬printº¯Êý
ºóÀ´¿´ÁËһϸüеÄÎĵµ²ÅÖªµÀ£¬3.0ÒÔºóprintÒѾ±»·â×°³Éº¯ÊýÁË
¶øÎÒ»¹Ò»Ö±Ï°¹ß2.6µÄ print 'Hello World'ÐÎʽ£¬ º¹Ò»¸ö£¡
ÎÊÌâ2£¬notepadµÄutf8¸ñʽ
ÎÒʹÓÃnotepadдÁ˸ö²âÊÔÎļþ£¬±£´æΪutf8¸ñʽ
¸ñʽ´ó¸ÅÊÇ:
test& ......
import sys, pygame, time
size = width, height = 700,700
fontColor = (0,0,255)
class walk:
'''This is a game about war.
Just like war 3.'''
def __init__(self):
'''Init the screen.
Get param and init the screen'''
#print ('this is init funnction') ......
Ò»¡¢Ê²Ã´ÊÇPython£¿
¶ÔÓÚÕâÖÖÎÊÌâÎÒÃÇÀ´°Ù¶ÈһϾͿÉÒÔÁË¡£
“PythonÊÇÒ»ÖÖ¿ª·ÅÔ´´úÂëµÄ½Å±¾±à³ÌÓïÑÔ£¬ÕâÖֽű¾ÓïÑÔÌرðÇ¿µ÷¿ª·¢ËٶȺʹúÂëµÄÇåÎú³Ì¶È¡£Ëü¿ÉÒÔÓÃÀ´¿ª·¢¸÷ÖÖ³ÌÐò£¬´Ó¼òµ¥µÄ½Å±¾ÈÎÎñµ½¸´Ôӵġ¢ÃæÏò¶ÔÏóµÄÓ¦ÓóÌÐò¶¼ÓдóÏÔÉíÊֵĵط½¡£Python»¹±»µ±×÷Ò»ÖÖÈëÃųÌÐòÔ±×îÊʺÏÕÆÎÕµÄÓÅÐãÓïÑÔ£¬ÒòΪËüÃâ·Ñ¡¢Ã ......
1£¬²»ÓÃÐÞ¸Ä/etc/vimϵÄvimrc¼°gvimrcÎļþ ¡£¡£¡£
2£¬ÔÚ~Ŀ¼Ï£¬Ð½¨Ò»¸ö.vimrcµÄÅäÖÃÎļþ¡£ÄÚÈÝÈçÏ£º£¨¸ßÁÁ£¬×Ô¶¯¶ÔÆ룬×Ô¶¯Ëõ½ø£¬ÏÔʾÐкţ©
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2006 Nov ......
1. µÚ¶þÕ Óï·¨¼°´úÂëÔ¼¶¨
&nb ......