首页 > 编程语言 > 详细

Python之first script

时间:2015-06-10 00:50:23      阅读:264      评论:0      收藏:0      [点我收藏+]

1  A first script

  1)  script1.py  

1 # A first Python script
2 import sys                  # Load a library module
3 print(sys.platform)
4 print(2 ** 10)             # Raise 2 to a power
5 x = Spam!
6 print(x * 8)                # String repetition

  this file:

  - Imports a Python module (libraries of additional tools), to fetch the name of the platform

  - Runs three print function calls, to display the script’s results

  - Uses a variable named x, created when it’s assigned, to hold onto a string object

  - Applies various object operations that we’ll begin studying in the next chapter

 

  2)  Run file

  Once save this text file, run it by listing its full filename as the first argument to a python command, typed at the system shell prompt:

% python script1.py

  The output result in my computer is 

linux2
1024
Spam!Spam!Spam!Spam!Spam!Spam!Spam!Spam!

 

Python之first script

原文:http://www.cnblogs.com/mengdie/p/4334101.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!