如何用for循环打印ASCII?

发布于 2025-01-29 20:34:22 字数 1720 浏览 2 评论 0原文

我试图制作一个为我绘制ASCII的程序,而BC IM懒于用原始字符串制作它,我用for loop制作它,我写了此程序,

import os
import random as rand
import time
from termcolor import colored

def cls():
  os.system('cls' if os.name == 'nt' else 'clear')
cls()

characters = [
  "a",
  "b",
  "c",
  "d",
  "e",
  "f",
  "g",
  "h",
  "i",
  "j",
  "k",
  "l",
  "m",
  "n",
  "o",
  "p",
  "q",
  "r",
  "s",
  "t",
  "u",
  "v",
  "w",
  "x",
  "y",
  "@",
  "#",
  "$",
  "&",
  "+",
  "(",
  ")",
  "/",
  "\"",
  "\'",
  "!",
  "?",
]

width = 10
height = 0

chars = []

#for i in range(300):
    #white = rand.choice(characters)
    #red = colored(rand.choice(characters), 'red')
    #cls()
    #print((white * 300) + (red * 300))
print(rand.choice(characters)*300)

这就是它显示的内容:

))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

某些随机字符从字符变量中

,这就是我想要的,我希望它向

Jhgakl+-&;#)9);$)"((@jhhkakllsb)))(+-@(+$8+!$;;"(#;))));;#+$!"+!#iajnsnnan($!(#!!#?#??#(!#oiiooqoojndnnna(((njakkakmsl(!;?#///bbjkakakKkxjbxjskakl(+;)))#/)(;$((@(

我展示试图与python制作ASCII艺术,有人可以帮助我解决这个问题吗?

Im trying to make a program that draws an ascii for me, and bc im lazy to make it with a raw string, im making it with a for loop, and i wrote this programs

import os
import random as rand
import time
from termcolor import colored

def cls():
  os.system('cls' if os.name == 'nt' else 'clear')
cls()

characters = [
  "a",
  "b",
  "c",
  "d",
  "e",
  "f",
  "g",
  "h",
  "i",
  "j",
  "k",
  "l",
  "m",
  "n",
  "o",
  "p",
  "q",
  "r",
  "s",
  "t",
  "u",
  "v",
  "w",
  "x",
  "y",
  "@",
  "#",
  "
quot;,
  "&",
  "+",
  "(",
  ")",
  "/",
  "\"",
  "\'",
  "!",
  "?",
]

width = 10
height = 0

chars = []

#for i in range(300):
    #white = rand.choice(characters)
    #red = colored(rand.choice(characters), 'red')
    #cls()
    #print((white * 300) + (red * 300))
print(rand.choice(characters)*300)

And this is what it shows:

))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

Or

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

Or some random characters from the characters variable

And this is what i want i want it to show

Jhgakl+-&;#)9);$)"((@jhhkakllsb)))(+-@(+$8+!$;;"(#;))));;#+$!"+!#iajnsnnan($!(#!!#?#??#(!#oiiooqoojndnnna(((njakkakmsl(!;?#///bbjkakakKkxjbxjskakl(+;)))#/)(;$((@(

Im trying to make an ascii art with python, can someone help me with this pls?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人接听 2025-02-05 20:34:22

使用random.choices而不是random.choice.choice,或使用循环:

print(''.join(rand.choices(character, k=300)))
print(''.join(rand.choice(character) for _ in range(300)))

Use random.choices instead of random.choice, or use loops:

print(''.join(rand.choices(character, k=300)))
print(''.join(rand.choice(character) for _ in range(300)))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文