测试使用代码插入功能

 
  
 1 my_name = 'Zed A. Shaw'
 2 my_age = 35 # not a lie
 3 my_height = 74 # inches
 4 my_weight = 180 # lbs
 5 my_eyes = 'Blue'
 6 my_teeth = 'White'
 7 my_hair = 'Brown'
 8 
 9 print "Let's talk about %s." % my_name
10 print "He's %d inches tall." % my_height
11 print "He's %d pounds heavy." % my_weight
12 print "Actually that's not too heavy."
13 print "He's got %s eyes and %s hair." % (my_eyes, my_hair)
14 print "His teeth are usually %s depending on the coffee." % my_teeth
15 
16 # this line is tricky, try to get it exactly right
17 print "If I add %d, %d, and %d I get %d." % (
18     my_age, my_height, my_weight, my_age + my_height + my_weight)
 
  
View Code
 1 #! usr/bin/env python
 2 
 3 #-*- coding:utf-8 -*-
 4 
 5 
 6 
 7 import string
 8 
 9 
10 
11 alphas=string.letters+'_'
12 
13 nums=string.digits
14 
15 
16 
17 print u'欢迎使用一次性标识符检查器1.0版.'
18 
19 print u'囧...\n暂时没找到检查结束后重回程序起点的办法.\n所以只好一次性了.'
20 
21 print u'请输入至少两个字符.'
22 
23 myinput=raw_input('>')
24 
25 if len(myinput)>1:
26 
27     if myinput[0] not in alphas:
28 
29         print u'傻逼,输个这玩意都能出错?!'
30 
31     else:
32 
33         for otherchar in myinput[1:]:
34 
35             if otherchar not in alphas+nums:
36 
37                 print u'傻逼,输个这玩意都能出错?!'
38 
39                 break
40 
41         else:
42 
43             print u'诶,好像不太对劲,让我再瞅瞅...啊呀呦,我勒个去!\n恭喜!合法标识符,鉴定完毕!'                                                

 

 

转载于:https://www.cnblogs.com/scoter/archive/2012/10/26/2740529.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值