2009年8月31日星期一

準備用Python寫點小東西,遇到的第一個問題:python 調用系統命令

python
Python 2.6.2 (r262:71600, Aug 19 2009, 12:13:04)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> os.system('ls')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'os' is not defined
###貌似沒有找到os這個東東(module)

>>> import os
>>> os.system('ls')
Desktop             rubyStudy
>>>

出來了.

没有评论:

发表评论