标签:style blog http color io os 使用 ar for
进入python:
[root@likun ~]# python Python2.6.5(r265:79063,Jul142010,11:36:05) [GCC 4.4.420100630(RedHat4.4.4-10)] on linux2Type"help","copyright","credits" or "license"for more information.>>> [root@likun ~]# cat hello.py #!/usr/bin/pythonprint‘hello!‘[root@likun ~]# [root@likun ~]# python hello.py hello!>>> name=‘Likun‘        --定义,并给变量赋值,字符类型要加引号>>> print nameLikun>>> name1=name        --变量之间传递赋值>>> print name1Likun>>> print ‘%s is good‘%name1       --%s 为变量占位符Likun is good>>> name1=addr            --addr未加引号,会当做变量而不是字符,找不到变量因此报错Traceback(most recent call last):  File"<stdin>", line 1, in <module>NameError: name ‘addr‘ is not defined[root@likun python_scripts]# cat 1hello.py #!/usr/bin/python print ‘hello!‘ print "what‘s your name?" n=‘‘‘good morning everyone, come on !‘‘‘ print n
[root@likun python_scripts]# cat 3rate.py #!/usr/bin/python print ‘The rate between HK$ and US$ to RMB\n‘ rmb =int(raw_input(‘input how much RMB you want to change:‘)) --int后才能做浮点运算 HK=rmb /0.84 US=rmb /6.4 print ‘HK=‘,HK,‘,US=‘,US --拼接用逗号
[root@likun python_scripts]# python 3rate.py The rate between HK$ and US$ to RMBinput how much RMB you want to change:10HK=11.9047619048,US=1.5625[root@likun python_scripts]# cat 1hello.py #!/usr/bin/python print ‘hello!‘ print ‘world‘ for i in range(1,5): print i
import sys import readline import rlcompleter import atexit import os readline.parse_and_bind(‘tab: complete‘) histfile = os.path.join(os.environ[‘HOME‘], ‘.pythonhistory‘) try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file, histfile) del os, histfile, readline, rlcompleter
标签:style blog http color io os 使用 ar for
原文地址:http://www.cnblogs.com/kissdb/p/4009558.html