�g�ݍ��݃c�[��

�c�[��(���W���[��)�̎g�����́u���C�u�������t�@�����X�v���Q�Ƃ���B ���C�u�������t�@�����X�́AWindows �p�ɂ̓X�^�[�g���j���[����J�����Ƃ��ł��邪�A �l�b�g��ł��APython Documentation Site ����ALibrary Reference ( ���{���v���W�F�N�g) �����ǂ�ƌ��邱�Ƃ��ł���B

�܂��Adir() ���g���ƃI�u�W�F�N�g�������Ă��鑮��(�����f�[�^�A���\�b�h�֐�)�� ���ׂ邱�Ƃ��ł��Atype() ���g���Ɓu�^�v�𒲂ׂ邱�Ƃ��ł���B

sys ���W���[��

�g�ݍ��݊֐�

�^�ϊ��A�����̑���A�v���O�����̎��s�Ȃ�

�v���O�����̎��s

>>> code = "x = 'Something'"
>>> x = "Nothing"
>>> exec code
>>> x
'Something'
>>> dict = {'x': 'Anything'}
>>> code = "print x"
>>> exec code in dict
Anything
>>> z = eval("'xo'*10")
>>> z
'xoxoxoxoxoxoxoxoxoxo'

������̑���

�V�����o�[�W������ Python �ł́Astring ���W���[���̂قƂ�ǂ̋@�\�́A ������^�I�u�W�F�N�g�̃��\�b�h�ɂȂ��Ă���B
>>> a = 'tomato'
>>> a.capitalize()
'Tomato'
>>> a = 'tomato\tpotato'
>>> a
'tomato\tpotato'
>>> print a
tomato	potato
>>> a.expandtabs()
'tomato  potato'
>>> a = 'now is the time'
>>> a.find('is')
4
>>> a.count('i')
2
>>> a.replace(' ', '_')
'now_is_the_time'
>>> a.split(' ')
['now', 'is', 'the', 'time']
>>> x = '*'
>>> x.join(a.split(' '))
'now*is*the*time'
>>> "   before and after   ".strip()
'before and after'

���x�ȕ�������: re ���W���[��

���K�\��

��{�I�Ȏg�����̗�
>>> import re
>>> s = 'abc def 012 xyz'
>>> re.match('a.*z',s)
<_sre.SRE_Match object at 0x00A98020>
>>> re.match('abc',s)
<_sre.SRE_Match object at 0x00AA0020>
>>> re.match('def',s)
>>> re.search('def',s)
<_sre.SRE_Match object at 0x00AA6140>
>>> x = re.search('def',s)
>>> x.start(), x.end()
(4, 7)
>>> s[x.start():x.end()]
'def'
>>> re.sub('def','rst',s)
'abc rst 012 xyz'
>>> re.sub('\d+','',s)
'abc def  xyz'
>>> y = re.match('.* (\d+) xyz',s)
>>> y.group(1)
'012'
>>> re.sub('^.* (\d+) xyz','\g<1> yen',s)
'012 yen'
>>> import string
>>> string.atoi(y.group(1))
12
��� Special Characters (���ꕶ��)
"."
(Dot) �S�Ă̕���
"^"
(Caret) ������̍ŏ�
"$"
������̍Ō�
"*"
���O�̐��K�\���̂O��ȏ�̌J��Ԃ�
"+"
���O�̐��K�\���̂P��ȏ�̌J��Ԃ�
"\"
(Backslash) ���̕����Ƒg�ݍ��킹�ē��ʂ̈Ӗ��̂���V�[�P���X��\�����A���̕����̓���ȈӖ���ł�����
[]
���ʂ̒��̕����̂ǂꂩ (�� [ab] [a-zA-Z])
()
���ʂ̒��̐��K�\���܂��͓K�����O���[�v������
\d
���� ([0-9])
\s
�󔒕��� ([ \t\n\r\f\v])
\w
�p���� ([a-zA-Z0-9_])
���K�\�����R���p�C�����ė��p����B
>>> s
'abc def 012 xyz'
>>> r = re.compile('^.* (\d+) xyz$')
>>> r.sub('\g<1> yen',s)
'012 yen'
>>> t = 'qwe asd ert 345 xyz'
>>> r.sub('\g<1> yen', t)
'345 yen'

�������W���[��

>>> import time
>>> time.asctime(time.localtime())
'Sun Jan 13 15:42:26 2002'
>>> time.time()
1010904182.54
>>> t = time.time()
>>> u = time.localtime(t)
>>> u
(2002, 1, 13, 15, 43, 40, 6, 13, 0)
>>> g = time.gmtime(t)
>>> g
(2002, 1, 13, 6, 43, 40, 6, 13, 0)
>>> time.asctime(g)
'Sun Jan 13 06:43:40 2002'
>>> time.strftime('%Y/%m/%d %H:%M:%S',u)
'2002/01/13 15:43:40'
>>> def test():
	a = time.time()
	time.sleep(20)
	b = time.time()
	print b - a
	
>>> test()
19.9900000095

HTTP �T�[�o

httptest.py ���X�N���v�g�Ƃ��Ď��s. ���s�f�B���N�g�������[�g�f�B���N�g���Ƃ��Č��J���� HTTP �T�[�o�� �ł���. (���ۂɂ� Apache HTTPd �̂悤��, �ŏ�����T�[�o�Ƃ��č��ꂽ ���̂𗘗p����ق����悢.)