简体   繁体   中英

Printing ASCII art from a file

I am working on a game, and I want to print ASCII art prizes from a file. I have to be able to print any specific prize in the file. The main problem is how to split the file into different prizes and how to store them. Does any one know how to do this?

In your Ascii file, between each ascii art, add a line that says, and only says, "SPLIT"

I assume you know how to open a file, so the following code is how to split each ascii art into a list.

>>> a = 'ascii1 SPLIT ascii2 SPLIT ascii3'
>>> a.split('SPLIT')
['ascii1 ', ' ascii2 ', ' ascii3']
>>> a.split('SPLIT')[1]
' ascii2'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM