1

file path is : "C:\SampleFile\Learnnowonline Bootstrap 3.1 Base CSS_git.ir\Learnnowonline Bootstrap 3.1 Base CSS_git.ir\01.Grid\0101.Introduction.mp4"

IOError: [Errno 22] invalid mode ('w') or filename: 'C:\SampleFile\Learnnowonline Bootstrap 3.1 Base CSS_git.ir\Learnnowonline Bootstrap 3.1 Base CSS_git.ir\x01.Grid\x081.Introduction_en.srt'

  • Is that file path a literal string in your script? If so, you should use a raw string so that the backslashes aren't interpreted as escape codes, Eg, `r"C:\SampleFile\Learnnowonline Bootstrap 3.1 Base CSS_git.ir\Learnnowonline Bootstrap 3.1 Base CSS_git.ir\01.Grid\0101.Introduction.mp4"` See https://stackoverflow.com/a/4780104/4014959 – PM 2Ring May 28 '18 at 06:01

1 Answers1

0

Change every backslash to double backslash.

In your case, change them to

"C:\\SampleFile\\Learnnowonline Bootstrap 3.1 Base CSS_git.ir\\Learnnowonline 
Bootstrap 3.1 Base CSS_git.ir\\01.Grid\\0101.Introduction.mp4"

Because python take \{digit} as unicode escape symbol. Change to \\ would solve this problem

  • Why not just a just use a raw string? – PM 2Ring May 28 '18 at 06:04
  • Also, `'\0{digit}'` is an octal byte code, where there can be up to 3 octal digits after the leading zero. A Unicode escape code starts with `'\u'` followed by 4 hex digits, or `'\U'` followed by 8 hex digits. – PM 2Ring May 28 '18 at 06:09