文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载