0

I'm getting this error, can someone show me where I went wrong.

import requests
import time
with open("C:\\temp\\cars.txt", 'r') as myfile:
  data1 = myfile.read()

searchKey = "ford="
searchEndKey = '"' 
auto = data1.text[data1.text.find(searchKey) + len(searchKey):
                  data1.text.find(searchEndKey, data1.text.find(searchKey) + 
                                                len(searchKey) + 1)]

with open("C:\\temp\\cars2.txt", "rt") as fin:
    with open("C:\\temp\\cars3.txt", "wt") as fout:
        for line in fin:
            fout.write(line.replace('ford=', 'ford='+auto))

AttributeError: 'str' object has no attribute 'text'

3
  • Why do you think a str would have a text attribute? Commented Mar 31, 2018 at 23:26
  • 4
    Start by removing the .text Commented Mar 31, 2018 at 23:46
  • Thank you, that worked - "Start by removing the .text" Commented Apr 1, 2018 at 0:23

1 Answer 1

3

As posted above, removed the .text Working now

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.