The file encad-inc-117.51.0.1-x64-clk-en-3-2.zip is a free information for encad inc 117.51.0.1. We are not provide any soft ware download from encad-inc-117.51.0.1-x64-clk-en-3-2.zip but we provides source of software from free file hosting service.Q:
How to read integers in a text file with python
I have a text file in the following format:
[the name]|[number]
I need to read the first character, then read the name and the number (in a tuple) from it. My code so far is:
infile = open("raw.txt", "r")
for line in infile:
line = line.strip()
if line.startswith("[name]"):
name = line.split("|")[1]
print name
elif line.startswith("[number]"):
number = line.split("|")[1]
print number
else:
print line
But this isn't giving me what I want. The problem is that I need to extract the number before printing the name. Any suggestions?
Edit: Thank you so much for your answers, they have been really helpful.
A:
You can try this:
infile = open("raw.txt", "r")
for line in infile:
name,number = line.split("|",1)
print name, number
A:
This should do it:
import re
with open('raw.txt') as f:
for line in f:
line = line.strip()
if line.startswith("[name]"):
name = line.split("|")[1]
elif line.startswith("[number]"): be359ba680
Related links:
Comments