码迷,mamicode.com
首页 > 其他好文 > 详细

背书吧!

时间:2014-09-16 14:19:20      阅读:350      评论:0      收藏:0      [点我收藏+]

标签:python


打乱了,找线索,拼起来,再背。

import random

s = '''
However, even NRZI can have long series of zeros (or ones if transitioning on "zero"),
and thus clock recovery can be difficult unless some form of run length limited
(RLL) coding is used in addition to NRZI. Magnetic disk and tape storage devices
generally use fixed-rate RLL codes, while USB uses bit stuffing, which inserts
an additional 0 bit after 6 consecutive 1 bits, thus forcing a transition.
While bit stuffing is efficient, it results in a variable data rate because
it takes slightly longer to send a long string of 1 bits than it does to send
a long string of 0 bits.
'''

ss = s.split()

text = []

while ss:
    r = random.randint( 4, 7 )
    t = reduce( lambda x, y : x + " " +y, ss[:r] )
    if random.random() < 0.3:
        choice = random.choice( ss[:r] )
        p = random.randint( 1, len( choice ) )
        t = t.replace( choice, "*" + choice[p:] + choice[:p] )
    text.append( t )
    ss = ss[r:]

random.shuffle( text )

for t in text:
    print " " * random.randint( 0, 15 ), t
    print 


背书吧!

标签:python

原文地址:http://blog.csdn.net/pandora_madara/article/details/39315795

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!