Contents

1 working directory 覲蟆
2 覲 一危壱 願鍵
3


1 working directory 覲蟆 #

import os
print os.getcwd() # working directory 願鍵
os.chdir('d:\pydata')

2 覲 一危壱 願鍵 #

>>> a = 'dynamic'
>>> x = type(a)
>>> x
<type 'str'>
>>> x.__name__
'str'
>>> 

觜蟲 れ螻 螳 蟆 譬 ..
>>> isinstance('aaa', str)
True
>>> isinstance(123, int)
True

3 #


  • expression -> a + 1
  • statments -> a = a + 1

expression
>>> a = 1
>>> a = eval('a+1')
>>> a
2

statment
>>> exec 'a = a + 1'
>>> a
3

ろ 螻朱 貉危殊 覦 . 蠏碁 貉危 蟆朱 ろ . expression企 statment 覈 貉危狩伎 .
>>> a = 1
>>> compiled_code = compile('a + 1', '<string>', 'eval')
>>> a = 1
>>> for i in range(5): 
...     a = eval(compiled_code)
...     
>>> a
6
compile() 3覯讌 語..
  • expression 企 'eval'
  • statment 企 'single'
  • 覲牛 statment 企 'exec'
襯 磯 .