创建一个文件
[root@bogon IP]# vim bash2.py
!/usr/bin/env python
import os
bash = os.popen('ls *.py').readlines()
print bash
测试:
[root@bogon IP]# chmod u+x bash2.py
[root@bogon IP]# python bash2.py
['bash2.py\n', 'bash.py\n', 'ip.py\n']
创建一个文件
[root@bogon IP]# vim bash2.py
import os
bash = os.popen('ls *.py').readlines()
print bash
测试:
[root@bogon IP]# chmod u+x bash2.py
[root@bogon IP]# python bash2.py
['bash2.py\n', 'bash.py\n', 'ip.py\n']