- 论坛徽章:
- 0
|
按照书上上的例子写了个程序 但是执行错误提示- @FUCK:~/python$ ./pysysinfo.py
- Traceback (most recent call last):
- File "./pysysinfo.py", line 22, in <module>
- main()
- File "./pysysinfo.py", line 19, in main
- uname_func()
- NameError: global name 'uname_func' is not defined
复制代码 程序如下- #!/usr/bin/python
- import subprocess
- def unmae_func():
- uname = "uname"
- uname_arg = "-a"
- print "gathering system information with %s command:\n" % uname
- subprocess.call([uname, uname_arg])
- def disk_func():
- diskspace = "df"
- diskspace_arg = "-h"
- print "gathering diskspace information %s command:\n" % diskspace
- subprocess.call([diskspace,diskspace_arg])
- def main():
- uname_func()
- disk_func()
- main()
复制代码 |
|