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";
    };

    .
    .
    .
有帮助吗?

解决方案

Do you mean this?

user_input = raw_input("prompt>")
print 'admin {'
for line in user_input.split('|'):
    print '"{0}";'.format(line.strip())
print '}'
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top