Esiste un modo per ignorare i caratteri di nuova riga nei dati immessi tramite raw_input? Sto cercando di utilizzare raw_input per inserire un elenco di stringhe che vengono copiate e incollate da un foglio di calcolo. il problema è che sembra che i caratteri della nuova riga causino l'immissione prematura dei dati. Tutti gli spazi vuoti saranno comunque rimossi, quindi rimuovere i newline non appena i dati saranno inseriti sarebbe un ulteriore vantaggio. Questi dati devono essere inseriti direttamente attraverso il prompt del terminale e non letti da un file.Python raw_input ignora newline
Questo è quello che ho fatto finora:
names = raw_input('Shoot me some names partner: ')
print 'What do you want to do?'
print '1 - format names for program 1'
print '2 - format names for program 2'
first_act = raw_input('Enter choice: ')
print names
print first_act
Ora, quando faccio funzionare questo e inserire i nomi fittizi che ho messo in un documento foglio di calcolo di Google da testare, non appena ho colpito shift + CTL + v , senza colpire entrare ottengo questo:
[email protected]:~> python pythonproj/names.py
Shoot me some names partner: abcd,efg,hijkl,mnop
abcd,efg,hijkl,mnop
abcd,efg,hijkl,mnop
abcd,efg,hijkl,mnop
abcd,efg,hijkl,mnop
abcd,efg,hijkl,mnop
abcd,efg,hijkl,mnop
abcd,efg,hijkl,mnopWhat do you want to do?
1 - format names for program 1
2 - format names for program 2
Enter choice: abcd,efg,hijkl,mnop
abcd,efg,hijkl,mnop
[email protected]:~> abcd,efg,hijkl,mnop
If 'abcd,efg,hijkl,mnop' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf abcd,efg,hijkl,mnop
[email protected]:~> abcd,efg,hijkl,mnop
If 'abcd,efg,hijkl,mnop' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf abcd,efg,hijkl,mnop
[email protected]:~> abcd,efg,hijkl,mnop
If 'abcd,efg,hijkl,mnop' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf abcd,efg,hijkl,mnop
[email protected]:~> abcd,efg,hijkl,mnop
If 'abcd,efg,hijkl,mnop' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf abcd,efg,hijkl,mnop
[email protected]:~> abcd,efg,hijkl,mnop
If 'abcd,efg,hijkl,mnop' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf abcd,efg,hijkl,mnop
[email protected]:~> abcd,efg,hijkl,mnop
sono abbastanza nuovo a Python, e io non sono il programmatore più esperto di gran lunga. Questo è Python 2.7.
Ciao, come devo dire a Python che ho finito il mio input? Ho provato '^ c', ma non ha funzionato. –