文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>python note

python note

时间:2009-03-17  来源:zsgd

1, about print
注意: 只要和字符串相关的都要有引号,单的双的都ok

2, 输出到文件
注意: 首先要open, 但不要忘记close

#!/bin/env python
import sys
outfile = open('/tmp/outfile.log','a')
user = raw_input("Please input your name:")
print >> outfile, user
outfile.close()

just to page 34

3,eg

#!/usr/bin/python
# Filename: while.py

number = 23
running = True

while running:
    guess = int(raw_input('Enter an integer : '))

    if guess == number:
        print 'Congratulations, you guessed it.'
        running = False # this causes the while loop to stop
    elif guess < number:
        print 'No, it is a little higher than that'
    else:
        print 'No, it is a little lower than that'
else:
    print 'The while loop is over.'
    # Do anything else you want to do here

print 'Done'

just page 52
相关阅读 更多 +
排行榜 更多 +
别惹神枪手安卓版

别惹神枪手安卓版

冒险解谜 下载
坦克战争世界

坦克战争世界

模拟经营 下载
丛林反击战

丛林反击战

飞行射击 下载