title: How can I assign the contents of a .txt file to a string variable in Python?
body: <p>I couldn't find an answer for this on StackOverflow, so I'm asking this question.</p>
  
  <p>I have a text file path stored in a variable called <code>settings_data_path</code> and I want to take whatever is in that text file and put it into a string variable, in this instance, <code>limited_n_ints</code>. So I opened the file and put it in a variable using</p>
  
  <pre><code>settings_data = open(settings_data_path, "r")
  limited_n_ints = (settings_data.read())
  print(limited_n_ints)
  settings_data.close()
  </code></pre>
  
  <p>Whenever I opened the data path with w+ and wrote something in the file, everything worked fine. However, when I print <code>limited_n_ints</code>, nothing shows up. Does anyone know how to store this file into a variable?</p>