I'm Getting "[errno 22] Invalid Argument: 'test.txt\r'
I'm experimenting with a python program that will allow you to edit text files, I will use this feature later on in other programs, but I get the error: [errno 22] Invealid argument: 'test.txt\r'. Also I never added \r to test.txt. Here is my code:
def menu(): print("Type in the full name of the text file you would like to add to.") file1 = input() with open(file1, "br") as add: print("What do you want to write?") text = input() add.write(text) menu()
Okay, new problem. I edited the code so that now it says
file1 = input().strip() and it worked fine ALL up until I got another error. The error is:
io:UnsupportedOperation: write. The error says it's in line 7 in the part that says
Nevermind, I changed the with
open(file1, "br") to with
open(file1, "a") and it works fine now. THANKS FOR ALL OF YOUR HELP GUYS!!!
file1 = input().strip()
input() returns the new line at the end and that makes the filename invalid.
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module