how do you store a variable in an external file [closed] - python

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 4 years ago.
Improve this question
So, i'm on assignment at school where i have create my own dice rolling game, i have completed everything but all i have to do now is store the scores that the user gets into a external file. I am new and have no idea how to do this, so could anybody help me out? Thanks!

You can try this kind of code.
with open(file, "a") as f:
f.write("write your content" + "\n")
But there are plenty of pages describing how to write content into files. Did you try these examples?
Reading and writing files in Python.

Related

Python machine learning for file renaming [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 3 days ago.
Improve this question
Let's say I have a dataset which contains lots of inputfilename and outputfilename. How should I go ahead if I want to make a machine learning model for this, so that I later on can inject a inputfilename and get a suggestion for outputfilename?
What libraries should I use? Any examples available?
Thanks!
I've tried googling but find no good comparable examples.

how can I observe a change in a python var [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 1 year ago.
Improve this question
Hi I'm trying to catch the change in the paperclip of my computer with the library pyperclip something same as
url=pyperclip.paste()
I want to create a thread which can append all the urls into a list my script, but I don't know how to could I do it
Thanks for your time and help c:
Did you check the documentation or the source code at all? That's all I did. pyperclip supports waitForPaste and waitForNewPaste methods that can do this.

Using txt files for multiple choice questions [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 1 year ago.
Improve this question
I am currently making a quiz through python and Tkinter. I’m trying to use txt files, one for my questions and one for my set of answers for the said question, as well as one for explanations for the answers. However, I’m not sure how to implement this into my code. I’m not sure how to retrieve a question from the txt file and represent it as a label while having the correct set of answers that are associated with that question and represent them as buttons for the user to choose. As well as display the text for the correct explanation for the answer.
You can write a function that do that. Something like:
def write_to_txt(path, my_word):
with open(path, "w") as my_txt:
my_txt.write(my_word)

Is it possible to print results on beat? [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 3 years ago.
Improve this question
I'm trying to print a list of sentences to the rhythm of a song, and have the python file play the song as well. Is there a way to print to a certain bpm, or have the file recognize the bpm of the song?
The Echo Nest Remix library might be able to help you here
Use this library to retrieve the BPM of the file and then use time.sleep() with a value in seconds that is the result of whatever interval you want.
Hope this helps - happy coding!

python overwrite and append to text 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
Iam new to python scripting.Please help me to open text file in overwrite and append mode
I want to overwrite text file which is already there for the first time looping starts and from next loop onwards , it should append the line to that text file.
Please help
Use this:
with open('/path/to/file', 'w') as outFile:
outFile.write("new contents\n")
That's it! Using with you do not even need to close the file yourself.

Categories