码迷,mamicode.com
首页 > 编程语言 > 详细

Python之first script

时间:2015-06-10 00:52:45      阅读:191      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!