_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › Python-Tip1

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'
襯 磯 .
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

企 覩(臂)手 蠍螳 覲伎譯朱 蠏碁襦 (臂) 伎襦 襴れ 覯企. 螻燕蠍郁 襴 苦 豢曙 襷譯朱 蟆 蠍(歎) 矩企. (<れ 8> 蟾一覿)