About 50 results
Open links in new tab
  1. How do I open a text file in Python? - Stack Overflow

    Oct 18, 2016 · Currently I am trying to open a text file called "temperature.txt" i have saved on my desktop using file handler, however for some reason i cannot get it to work. Could anyone tell me …

  2. function - How to Open a file through python - Stack Overflow

    Oct 22, 2013 · I am very new to programming and the python language. I know how to open a file in python, but the question is how can I open the file as a parameter of a function? example: function …

  3. How to open a file using the open with statement - Stack Overflow

    I'm looking at how to do file input and output in Python. I've written the following code to read a list of names (one per line) from a file into another file while checking a name against the names in the file …

  4. How to open and edit an existing file in Python? - Stack Overflow

    Dec 16, 2014 · The open() built-in Python method (doc) uses normally two arguments: the file path and the mode. You have three principal modes (the most used): r, w and a.

  5. python - How can I read a text file into a string variable and strip ...

    315 In Python 3.5 or later, using pathlib you can copy text file contents into a variable and close the file in one line:

  6. python - How do I read a text file as a string? - Stack Overflow

    Nov 12, 2018 · 29 text_file.readlines() returns a list of strings containing the lines in the file. If you want only a string, not a list of the lines, use text_file.read() instead. You also have another problem in …

  7. Open file in a relative location in Python - Stack Overflow

    Aug 24, 2011 · Suppose my python code is executed a directory called main and the application needs to access main/2091/data.txt. how should I use open (location)? what should the parameter location …

  8. Open File in Another Directory (Python) - Stack Overflow

    Sep 9, 2015 · \subfldr1 -testfile.txt \subfldr2 -fileOpener.py I'm trying to script in fileOpener.py to get out of subfldr2, get into subfldr1, and then call an open () on testfile.txt. From browsing stackoverflow, …

  9. How do I print the content of a .txt file in Python?

    Aug 15, 2013 · Anyways, I'm working on a piece of code that will open a file, print out the contents on the screen, ask you if you want to edit/delete/etc the contents, do it, and then re-print out the results …

  10. Add lines to existing file using Python - Stack Overflow

    I already created a txt file using python with a few lines of text that will be read by a simple program. However, I am having some trouble reopening the file and writing additional lines in the fi...