'invalid argument' error and python not reading file -



'invalid argument' error and python not reading file -

i trying write code takes 2 numbers in text file , divides them, showing reply top heavy fraction. have gotten fractions part work when inputting own values in program, cannot programme recognise text file. have tried putting them in same directory , putting total scheme path of file, nil far has worked. right trying contents of file print.

with open('c:\programdata\microsoft\windows\start menu\programs\python 3.4\topheavy.txt','w') f: line in f: word in line.split(): print(word)

i assign 2 values x , y, error:

traceback (most recent phone call last): file "c:\python34\divider.py", line 2, in <module> open('c:\programdata\microsoft\windows\start menu\programs\python 3.4\topheavy.txt','w') oserror: [errno 22] invalid argument:'c:\\programdata\\microsoft\\windows\\startmenu\\programs\\python 3.4\topheavy.txt'

thanks help.

open('c:\programdata\microsoft\windows\start menu\programs\python 3.4\topheavy.txt','w') oserror: [errno 22] invalid argument:'c:\\programdata\\microsoft\\windows\\startmenu\\programs\\python 3.4\topheavy.txt'

two things:

when working paths contain backslashes, either need utilize 2 backslashes, or utilize r'' form prevent interpreting of escape sequences. example, 'c:\\program files\\...' or r'c:\program files\...'. your error shows this: \\startmenu\\. appears space missing between "start" , "menu", despite fact open line seems have right path.

note: \topheavy.txt in path getting converted <tab>opheavy.txt too. that's why there aren't 2 backslashes in front end of in traceback.

python file

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -