别人的代码

# -*- coding: cp936 -*-
"""
import string
import copy
inputString=raw_input("请输入你要判断的字符串:")
punctuation=string.punctuation #sting.punctuation里面包含了32个英文标点符号
identify=' '*32
table=string.maketrans(punctuation,identify)#makerans接受两个等长的参数,形成一个对应表
new=inputString.translate(table).replace(' ','')#先用对应表和translate函数将字符串
#里面的标点符号用空格代替,然后去掉空格
 
inputString=list(new)#转换成列表,为的是使用反转函数
temp=copy.deepcopy(inputString)#深拷贝,这里我纠结了好久,如果只是用简单的等于号的话,
#那样只是引用而已,inputstring改变了,temp也会改变的,所以要深拷贝
inputString.reverse()#将列表反转
print inputString#打印出列表,为的是输出结果的时候,能观察上面的操作结果如何
print temp
if temp==inputString:#判断是否相等
    print "是回文"
else:
    print "不是回文"
"""
#!/usr/bin/env python
def gongyueshu(m,n):
 if m<n:
  small = m
 else:
  small = n
 for i in range (small,0,-1):
  if m % i == 0 and n %i == 0:
   return i
def gongbeishu(m,n):
 gongyue = gongyueshu(m,n)
 return (m*n)/gongyue

gong = gongyueshu(m=10, n=3)
print gong
gongbei = gongbeishu(m=10,n=3)
print gongbei

def gongyue(m,n):
     return max([x for x in range(min(m, n),0,-1) if m%x==0 and n%x==0])
#http://www.oschina.net/code/snippet_105637_22437
#http://timgolden.me.uk/python/win32_how_do_i/copy-a-file.html复制文件方法

 

# -*- coding: utf-8 -*-
import Image,ImageDraw,ImageFont
import random
import math, string 

class RandomChar():
  """用于随机生成汉字"""
  @staticmethod
  def Unicode():
    val = random.randint(0x4E00, 0x9FBF)
    return unichr(val) 

  @staticmethod
  def GB2312():
    head = random.randint(0xB0, 0xCF)
    body = random.randint(0xA, 0xF)
    tail = random.randint(0, 0xF)
    val = ( head << 8 ) | (body << 4) | tail
    str = "%x" % val
    return str.decode('hex').decode('gb2312') 

class ImageChar():
  def __init__(self, fontColor = (0, 0, 0),
                     size = (100, 40),
                     fontPath = 'wqy.ttc',
                     bgColor = (255, 255, 255),
                     fontSize = 20):
    self.size = size
    self.fontPath = fontPath
    self.bgColor = bgColor
    self.fontSize = fontSize
    self.fontColor = fontColor
    self.font = ImageFont.truetype(self.fontPath, self.fontSize)
    self.image = Image.new('RGB', size, bgColor) 

  def rotate(self):
    self.image.rotate(random.randint(0, 30), expand=0) 

  def drawText(self, pos, txt, fill):
    draw = ImageDraw.Draw(self.image)
    draw.text(pos, txt, font=self.font, fill=fill)
    del draw 

  def randRGB(self):
    return (random.randint(0, 255),
           random.randint(0, 255),
           random.randint(0, 255)) 

  def randPoint(self):
    (width, height) = self.size
    return (random.randint(0, width), random.randint(0, height)) 

  def randLine(self, num):
    draw = ImageDraw.Draw(self.image)
    for i in range(0, num):
      draw.line([self.randPoint(), self.randPoint()], self.randRGB())
    del draw 

  def randChinese(self, num):
    gap = 5
    start = 0
    for i in range(0, num):
      char = RandomChar().GB2312()
      x = start + self.fontSize * i + random.randint(0, gap) + gap * i
      self.drawText((x, random.randint(-5, 5)), RandomChar().GB2312(), self.randRGB())
      self.rotate()
    self.randLine(18) 

  def save(self, path):
    self.image.save(path)

ic = ImageChar(fontColor=(100,211, 90))
ic.randChinese(4)
ic.save("1.jpeg")

 

 

 

 

 

 

 


   


def weekends_between(d1,d2):
    days_between = (d2-d1).days
    weekends, leftover = divmod(days_between,7)
    if leftover:
        start_day = (d2-timedelta(leftover)).isoweekday()
        end_day = start_day+leftover
        if start_day<=6 and end_day>6:
            weekends +=.5
        if start_day<=7 and end_day>7:
            weekends +=.5
    return weekends

weekends_between(date(2004,10,1),date(2004,10,10))

# -*- coding: cp936 -*-
def chinese_zodiac(year): 
     return u'猴鸡狗猪鼠牛虎兔龙蛇马羊'[year%12] 
 
def zodiac(month, day): 
    n = (u'摩羯座',u'水瓶座',u'双鱼座',u'白羊座',u'金牛座',u'双子座',u'巨蟹座',u'狮子座',u'处女座',u'天秤座',u'天蝎座',u'射手座') 
    d = ((1,20),(2,19),(3,21),(4,21),(5,21),(6,22),(7,23),(8,23),(9,23),(10,23),(11,23),(12,23)) 
    return n[len(filter(lambda y:y<=(month,day), d))%12] 

# -*- coding: cp936 -*-
"""
import os,time;
rh=int(time.strftime("%H",time.localtime()));
rm=int(time.strftime("%M",time.localtime()));
cmd="cmd.exe /k shutdown -s -t 0";
c1=True;
while c1:
    try:
        h=int(raw_input("Please input the hour:"));
        if h>=0 and h<=23:
            c1=False;
        else:
            continue;
    except:
        continue;
c2=True;
while c2:
    try:
        m=int(raw_input("Please input the minute:"));
        if m>=0 and m<=59:
            c2=False;
        else:
            continue;
    except:
        continue;
if h==rh:
    if m<=rm:
        os.system(cmd);
    else:
        time.sleep((m-rm)*60);
        os.system(cmd);
elif h>rh:
    tem1=(h-rh-1)*3600+(60-rm+m)*60;
    time.sleep(tem1);
    os.system(cmd);
else:
    tem2=(23-rh+h)*3600+(60-rm+m)*60;
    time.sleep(tem2);
    os.system(cmd);

"""
#coding:utf-8
t1 = []
t2 = []
#在列表中添加了48以验证最后一个数不连续的情况
a = [3,4,5,6,7,10,11,12,15,16,17,19,20,21,22,23,24,42,43,44,45,46,48]
for x in a:
    t1.append(x)
    if x+1 not in a:
        t2.append([t1[0], t1[-1]])
        t1 = []
print t2

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
 
import base64
 
class female:
 
    @property
    def age(self):
        templet = lambda s: '{:s} {:d} 岁'.format(s, self.__age)
        if self.__age < 21:
            return templet('芳龄')
        elif 22<self.__age  < 26:
            return templet('美眉')
        elif 27< self.__age <33:
            return templet('阿姨')
        else:
            return templet('大妈')
 
    @age.setter
    def age(self, value):
        if 16<value or value>60:
            raise ValueError('屌丝……请不要糟蹋少女或者口味太重啦!')
        elif value > 17 or value<35:
            raise ValueError('屌丝……你幸福了啦!')
        elif value>36 or value<8:
            print'好人呀,妈妈'
        else:
            if '_female__age' in dir(self):
                if self.__age > value:
                    raise ValueError('屌丝……时间可以倒流的吗?!')
        self.__age = value
 
    @age.deleter
    def age(self):
        raise SystemError('屌丝……年轮是可以删除的吗?!')
 
    @property
    def breif(self):
        STR = b'CC44rqL6V2Y5vip5g2L5GqL5Oip5B+K6fmL53Cq5MCZ5My77/y45Pqb5Li65vip5g2L5Oip5B+K6My77ESa5k2q5wiY5Ly55g2L5T2b5'
        return base64.b64decode(STR[::-1]).decode('UTF-8')
 
if __name__ == '__main__':
    a= female()   # 程序猿没有女朋友怎么办, New一个呗!
    print dir(a)
    a.age=38
    print a.age
    print a.breif

 

 

 

 

 

 

 

import math
def fact_tail_zero_count(x):
 return sum( int(x/5**(i+1)) for i in range( int(math.log(x,5)) ))

print fact_tail_zero_count(100)
print fact_tail_zero_count(10**8)

 

 

 

 

 


   
 

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值