|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Text/Input Question
Hello,
I have a text file that contains names.. Sally Jenni Jess and I want to take those names and run them through a program so the out put looks like this... "Sally", "Jenni", "Jess", Any Help would be appreciated. Thanks again! |
|
#2
|
||||
|
||||
|
names.txt
Code:
Sally Jenni Jess Names.py Code:
for x in file('names.txt'):
lines = x.splitlines( )
print lines
Output Code:
['Sally'] ['Jenni'] ['Jess'] Hopefully this is what you want ![]()
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev |
|
#3
|
|||
|
|||
|
Not exactly, but I can work from there.
Thanks again! |
|
#4
|
||||
|
||||
|
This any better?
Code:
#!/usr/bin/env python
for line in file('names.txt'):
print '"%s",' % line.strip()
Mark. |
|
#5
|
|||
|
|||
|
Mark, that works perfectly.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Text/Input Question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|