Python code will not compare from a text file [closed] - python

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 7 days ago.
Improve this question
This is a simplified version of my code for troubleshooting, its prints what it have to input in the comparison
this is the code running, it reads from the file but wont compare it to my input and gives the incorrect output
here is the text file
I just want the code to read from the file and have it compare to my input thank you :)
I've tried making the content of the file strings and variables for comparison but still the same result.

Related

How to close a file opened with a shortcut [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 6 days ago.
Improve this question
I know that it already exists a type of this question but I don't find the answer.
I have for example an pdf file opened (not with code) and I want to close that with python code.
I am beginner and I didn't succeed, to my shame :(((

Problem wih virtual keyboard not write in correct please [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 days ago.
Improve this question
I tryvto make virtual keyboard
It work But the problem is when I try to write with it
It's right hereenter image description here
What I actually want is to wrte In real desktop program like word ,note and so on
Please tell me if you want the code
Oh how can I fix it

If condition is True, output a txt file to directory path with a message [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
I am looking to output a text file with a certain message to a directory path if the below results is a 'True'.
df['Fraud Account'].isnull().values.any()
Is there a way to do this in Jupyter notebook?
Thank you!
I'm not 100% sure what you mean, but reading literally your question I think the answer would be sth like that:
if df['Fraud Account'].isnull().values.any():
open("my_file.txt", "wt").write("My message")
Contents of file would be replaced. If you wanted to append, you just replace wt by at in second parameter.

Read first line of a raw text [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 2 years ago.
Improve this question
Hey Im using my little scraper and I want to save results with one detail, first line of a raw pastebin/any other bin webpage.
lets say I have this code:
r=requests.get("https://pastebin.com/raw/qH03hKGU") #random link
text=r.text
I want to get the first line of the variable text without saving it (I will save just the one line)
You can use partition('\n')[0] to get the first line:
import requests
r=requests.get("https://pastebin.com/raw/qH03hKGU") #random link
text=r.text
print(text.partition('\n')[0])
OUT: import glob

How to save variable into a file (like print but into file)? [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 2 years ago.
Improve this question
I am asking how to save a text file in python, that can contain a variable.
I didn't tried anything because I am a beginner.
Let's say you have a file called file and it is a notepad (text/txt) document. Your code would go like this:
text = "This can be anything"
with open("file.txt", "w") as myfile:
myfile.write(text)
The tutorial on reading and writing files should help if you don't understand this. The w means that you can write to the file.

Categories

Resources