发布时间:2019-08-27 07:59:46编辑:auto阅读(1861)
在前面的尝试过程中没有什么甜头,多么无聊的输出预定义的内容,接下来说写点活的,真正感受一下程序的魅力:
在python中提供了raw_input
>>> name = raw_input("what is you name? ") what is you name? yuefan >>> print name yuefan
感觉有点意思啦,接下来玩个猜数字游戏遛遛:
# cat magic_num.py #/usr/bin/env python #coding: utf-8 a = 15 guess = 0 while a != guess: guess = input("猜数字,输入个数字试试: ") # print a,type(a), guess, type(guess) if guess < a: print "不对,小啦。\n" elif guess > a: print "不对,大啦。\n" print "不错啊,搞对啦!!!!"
这个可以让我的儿子玩玩啦,接下来把电脑时间交给儿子……
上一篇: python中Unicode和UTF-8
下一篇: python实例:公司应用(二)
48866
47932
38707
35858
30284
27039
26070
20903
20698
19066
501°
594°
604°
609°
586°
572°
635°
710°
828°
928°