本文整理汇总了Python中arduino.Arduino.meanrand方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.meanrand方法的具体用法?Python Arduino.meanrand怎么用?Python Arduino.meanrand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arduino.Arduino
的用法示例。
在下文中一共展示了Arduino.meanrand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Arduino
# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import meanrand [as 别名]
#coding: utf-8
"""Just a short program that grabs a bitstring s and writes to a file or whatever"""
from arduino import Arduino
from stattests import StatTests
from sys import stdin, argv
ard = Arduino()
# FIPS 140-1 demands a bitstring s of length 20 000.
# l = 20000
l = 1000
s = ''.join([a for a in ard.meanrand(l)])
st = StatTests(s)
print st.monobit()
# File stuff
# fname = argv[1] if len(argv) > 1 else 's.txt'
# f = open(fname, 'w')
# s = ''.join([a for a in ard.meanrand(l)])
# f.write(s)
# f.close()
示例2: len
# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import meanrand [as 别名]
import sys
if len(sys.argv) == 1:
print "missing alg"
sys.exit()
algorithm = sys.argv[1]
k = int(sys.argv[2])
ard = Arduino()
print algorithm
# ...
if algorithm == 'meanrand':
s = ''.join(ard.meanrand(k))
elif algorithm == 'updownrand':
s = ''.join(ard.updownrand(k))
elif algorithm == 'mix':
s = ''.join(ard.mixmeanupdown(k))
elif algorithm == 'leastsig':
s = ''.join(ard.leastsigrand(k))
elif algorithm == 'twol':
s = ''.join(ard.twoleastsignrand(k))
elif algorithm == 'vanilla':
s = ''.join(ard.vanilla(k))
if "-p" in sys.argv:
print s