0

I'm new to programming and this is my second script written in python. The code works fine in my programming environment. However, when I run it in cmd I get the following error:

Traceback (most recent call last):   File
"C:\FS1\Python\Stiffness_punch\main.py", line 34, in <module>
    with open(project_status) as f: IOError: [Errno 22] Invalid argument: '004.pch\r'

Here is the code:

print('Specify the name of the status project .pch file')
project_status = input("")

with open(project_status) as f:
    status_lines = f.readlines()

I couldn't find any solution. As I understand the name of the file is being interpreted as "004.pch\r" instead of "004.pch", but I have no idea how to remove this "\r" from the name of the file.

Piotr
  • 1
  • 1
  • Possible duplicate of [Python "IOError: \[Errno 22\] Invalid argument" when using cPickle to write large array to network drive](http://stackoverflow.com/questions/4226941/python-ioerror-errno-22-invalid-argument-when-using-cpickle-to-write-large) – apxp Feb 15 '16 at 09:47
  • Need to remove the "\r" using slicing operation. – Manjunath N Feb 15 '16 at 09:50
  • 1
    Can you please show how are you putting the input to the script in cmd? – shaktimaan Feb 15 '16 at 09:53
  • And may be this can help : http://stackoverflow.com/questions/27031726/python-3-2-ioerror-errno-22-invalid-argument-home-pi-data-temp-file1-n-tx – shaktimaan Feb 15 '16 at 09:59

1 Answers1

0

Try this:

project_status = input("").strip().replace('\"', '')
Ferrarezi
  • 801
  • 10
  • 12