Python Forum
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Errno 22] Invalid argument
#5
you are on Windows, that uses backslash as path separator \ However for python this is escape char, so you need to use forward slash or raw string or escape the backslash. In addition you should use with context manager when open the file. It will close the file for you at the end (something you don't do in your code)

with open('E:/baby2008.txt','r') as f:
# do something here
with open(r'E:\baby2008.txt','r') as f:
# do something here
with open('E:\\baby2008.txt','r') as f:
# do something here
Reply


Messages In This Thread
[Errno 22] Invalid argument - by satyaneel - Sep-27-2017, 07:06 AM
RE: [Errno 22] Invalid argument - by buran - Sep-27-2017, 07:31 AM
RE: [Errno 22] Invalid argument - by satyaneel - Sep-27-2017, 08:00 AM
RE: [Errno 22] Invalid argument - by snippsat - Sep-27-2017, 08:13 AM
RE: [Errno 22] Invalid argument - by buran - Sep-27-2017, 08:16 AM
RE: [Errno 22] Invalid argument - by satyaneel - Sep-27-2017, 08:18 AM
RE: [Errno 22] Invalid argument - by LOVESN - Feb-11-2020, 02:20 PM
RE: [Errno 22] Invalid argument - by snippsat - Feb-11-2020, 03:01 PM
RE: [Errno 22] Invalid argument - by LOVESN - Feb-11-2020, 03:24 PM
RE: [Errno 22] Invalid argument - by tdandwa - May-18-2020, 10:51 PM
RE: [Errno 22] Invalid argument - by lichunming - Jul-14-2020, 07:39 AM
RE: [Errno 22] Invalid argument - by lichunming - Jul-14-2020, 08:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Invalid argument: 'images\x08ackground.jpg' CatBall 4 1,046 Jun-19-2023, 09:28 AM
Last Post: CatBall
  [split] [Errno 22] Invalid argument Junaid 0 2,328 Jun-12-2021, 06:02 PM
Last Post: Junaid
  zlib decompress error: invalid code lengths set / invalid block type DreamingInsanity 0 6,964 Mar-29-2020, 12:44 PM
Last Post: DreamingInsanity
  SyntaxError: positional argument follows keyword argument syd_jat 3 5,922 Mar-03-2020, 08:34 AM
Last Post: buran
  Invalid argument error thrown. pyseeker 4 8,695 Sep-10-2019, 07:03 PM
Last Post: pyseeker
  OSError: [Errno 22] Invalid argument - wasn't there last time I ran the code! meganhollie 2 9,299 Jun-11-2018, 06:01 PM
Last Post: meganhollie
  [SOLVED] OSError: [Errno 22] Invalid argument Panda 13 44,336 Jun-04-2018, 08:33 PM
Last Post: volcano63
  [Errno 22] Invalid argument Asafb 8 13,693 Dec-19-2017, 12:52 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020