Python学习笔记2

来源:互联网 发布:sql查询数据库的大小 编辑:程序博客网 时间:2024/06/16 19:26

Python source code

 

When a Python file is run directly, the special variable "__name__" is set to "__main__". 

 

There is hello.py file as follows:

 

import sysdef main():    print 'Hello,', sys.argv[1]if __name__ == '__main__':    main()


We can run in the IPyhton:

run hello.py Michael

 

And the result is:

Hello, Michael

0 0
原创粉丝点击