문제

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