Frage

I'm making a configuration file generator and need to parse text into multiple lines without limiting the lines they want to use, so they have as many as they want. The exact example of this would be the /admin command on IRC, like the following would be what is put in and printed out:

    What are your admin {} lines? (delimited with some character.. lets say |)
    prompt> Nickname: Iota | Real Name: Fat Chance | Email: iota{at}electrocode.net
    .
    .
    .
    (after everything else is done its printed out/echoed or added to a file(what I plan on doing)
    admin {
        "Nickname: Iota";
        "Real Name: Fat Chance";
        "Email: iota{at}electrocode.net";
    };

    .
    .
    .
War es hilfreich?

Lösung

Do you mean this?

user_input = raw_input("prompt>")
print 'admin {'
for line in user_input.split('|'):
    print '"{0}";'.format(line.strip())
print '}'
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top