我如何说:"写将创建(随机数在这里)随机数

时间:2015-11-14 07:57:42

标签: python

我如何说:"写入将创建(随机数在这里)随机数

def main():

    # Open a file for writing
    outfile = open ('mynumbers.txt' , 'w')

    # Generate random integer number
    from random import randint
    print(randint(0,9))

main()

1 个答案:

答案 0 :(得分:1)

你的意思是以下几点吗?

from random import randint

number = randint(0, 9)
print("Write will create", number, "random numbers")

或者

from random import randint

number = randint(0, 9)
print("Write will create %d random numbers" % number)