Chinaunix

标题: Python代码片段 [打印本页]

作者: rleon    时间: 2008-06-19 20:43
标题: Python代码片段
get system platform  
[color="#800080"]>>> os.name
[color="#800080"]'posix'
[color="#800080"]>>> sys.platform
[color="#800080"]'linux2'
[color="#800080"]>>>   
get HOME path  
[color="#800080"]>>> os.environ['HOME']
[color="#800080"]'/home/rui'
[color="#800080"]>>> os.system('echo $HOME')
[color="#800080"]/home/rui
[color="#800080"]0
[color="#800080"]>>>   
get command line   
[color="#800080"]>>> sys.argv
[color="#800080"]['']
[color="#800080"]>>>   
--
海阔天空,做什么就记什么。主要是 Ubuntu Linux 和 Latex 及编程相关的东东:
http://hai-kuo.blogspot.com/

               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/71864/showart_1005675.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2