python TypeError: must be encoded string without NULL bytes, not str

前端 未结 3 1070
温柔的废话
温柔的废话 2021-01-12 04:08

Trying to get familiar with python\'s standard library and doing some mucking around with it on my Windows machine. Using python 2.7 I have the following little script whic

相关标签:
3条回答
  • 2021-01-12 04:36

    "...Photos\Modified\0-PyTest"

    Its taking the \0 as a null character. You have to escape \ using \\, or just put an r before the string to make it raw:

    r'C:\Users\me\Photo Projects\Project Name\Project Photos\Modified\0-PyTest'
    
    0 讨论(0)
  • 2021-01-12 04:38

    If you are giving a path url just add r before it :

    (r'E:\Images\1.png')

    0 讨论(0)
  • 2021-01-12 04:47

    turns out to be the single backslash problem. i thought os.path.normpath would format the path as required by the os.

    0 讨论(0)
提交回复
热议问题