How to check if file has been closed? python3 [closed] - python-3.x

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Im looking for a way to check if file is now closed (you know for sure that he was opened before).
Also Im need that the checking process will keep hapening until the file is actually closed by the user.

Use a context manager:
with open("/some/file.txt") as fin:
text = fin.read()
# Do stuff, possibly involving user input
print("File is now closed.")
The with arranges for fin.close() to be called upon exiting
that code block.

Related

How to scan a folder for unused images Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 11 months ago.
Improve this question
I have a folder of images.
I want to read all images and do some processing.
But next time if I run the script again, it should not consider already processed image, only new one.
What is the conventional way to do this?
You could use sqlite to store data about already know files https://docs.python.org/3/library/sqlite3.html
Later you could expanse the idea and use SQL to get bigger goals as "when it was processed" "what command you used to process"

How to change specific part of a string? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
For example, I have a string like this
a = "starlight sunlight"
And I want to change it into
a = "starspot sunspot"
well i guessed you writing this in python so you can use the replace method
enter example
in your case you went to replace the word light with the word spot so just write
a=a.replace("light","post")

Ask the user for its name using raw_input [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How do I write a program that uses raw_input to prompt a user for their name and then welcomes him.
For example that asks: Enter your name, and then the program continues welcoming the user with Hello NAME_OF_THE_USER
This is one of the easiest problem ever. This is my solution (since you tagged your post for Python 3):
name = input('Enter your name: ')
print("Welcome", name)
For Python 2, just change input to raw_input, and remove the parenthesis of the print function.

how to avoid getting ^M in file? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I don't know why it appears in my file when using vim.
Sometimes not in the vim, but in the output of 'git diff', why?
what command can help me check if file under some dir have '^M' problem, and fix all of them?

How to read an excel file in go? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm new on the go lang.I want to read an excel file for procees it later, but I don't know how to read the file in go? Anyone can show me an example ?
I haven't tried it but there's an xlsx package.
Install it with
go get -v github.com/tealeg/xlsx
Read the documentation and come back here with some code you've tried if you get stuck.
The go-ole package looks like a way to go if you want to drive an Excel process via COM to read your file.

Resources