如果我需要x个字符来测试我的程序,有没有办法用linux中的终端快速生成它们? 还是在python中? 例如,我想测试当我输入80个字符时我的程序是否中断。 但是,我希望能够在终端中生成80个字符,然后将其粘贴到我的程序(或管道等),而不是写80个字符。 我尝试过:
>>> for item in range (1,80): ... print "x",它可以工作,但它打印x,中间有空格,超过80个字符
If i need x amount of characters to test my program, is there a way of generating them quickly with terminal in linux? or in python? for example I want to test if my program breaks when I enter 80 characters. But instead of writing 80 characters I want to be able to just generate 80 characters in terminal and then copy paste it to my program (or pipeline it etc). I tried doing:
>>> for item in range (1,80): ... print "x",It works but it prints x with spaces inbetween which would be more than 80 characters
最满意答案
它必须是'x'吗? 对于随机字符串,您可以在shell中使用它
$ dd if=/dev/urandom count=80 bs=1Does it have to be 'x's? For a random string you can use this from the shell
$ dd if=/dev/urandom count=80 bs=1更多推荐
发布评论