I am creating a list of nested dictionaries to have the file addresses for images I will be using for my program. However, in the BU0 dictionary it seems to cause an error that reads:
JavaScript
x
2
1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 20-21: truncated UXXXXXXXX escape
2
Here is the nested list:
JavaScript
1
21
21
1
Bases = [
2
{
3
"BC0": ["Owl_project_picturesCommonGreat Grey Owl_greatgrey_base.PNG", "Owl_project_picturesCommonGreat Grey Owl_greatgrey_bonus1.PNG",
4
"Owl_project_picturesCommonGreat Grey Owl_greatgrey_bonus2.PNG", "Owl_project_picturesCommonGreat Grey Owl_greatgrey_accent.PNG",
5
"Owl_project_picturesCommonGreat Grey Owl_greatgrey_shadows.PNG", "Owl_project_picturesCommonGreat Grey Owl_greatgrey_eyesbeakfeet.PNG",
6
"Owl_project_picturesCommonGreat Grey Owl_greatgrey_lines.PNG"],
7
"BC1": ["Owl_project_picturesCommonBarn Owl_barn_base.PNG", "Owl_project_picturesCommonBarn Owl_barn_bonus1.PNG",
8
"Owl_project_picturesCommonBarn Owl_barn_bonus2.PNG", "Owl_project_picturesCommonBarn Owl_barn_bonus2.PNG",
9
"Owl_project_picturesCommonBarn Owl_barn_accent.PNG", "Owl_project_picturesCommonBarn Owl_barn_shadows.PNG",
10
"Owl_project_picturesCommonBarn Owl_barn_eyesbeakfeet.PNG", "Owl_project_picturesCommonBarn Owl_barn_lines.PNG"],
11
"BC2": ["Owl_project_picturesCommonBurrowing Owl_burrowing_base.PNG","Owl_project_picturesCommonBurrowing Owl_burrowing_bonus1.PNG",
12
"Owl_project_picturesCommonBurrowing Owl_burrowing_bonus2.PNG", "Owl_project_picturesCommonBurrowing Owl_burrowing_accent.PNG",
13
"Owl_project_picturesCommonBurrowing Owl_burrowing_shadows.PNG", "Owl_project_picturesCommonBurrowing Owl_burrowing_eyesbeakfeet.PNG",
14
"Owl_project_picturesCommonBurrowing Owl_burrowing_lines.PNG"]
15
},
16
{
17
# The section that causes the error
18
"BU0": ["Owl_project_picturesUncommonCrested Owl_crested_base.PNG", "Owl_project_picturesUncommonCrested Owl_crested_bonus1.PNG"]
19
}
20
]
21
Advertisement
Answer
Try to escape the backslashes:
JavaScript
1
11
11
1
2
3
{
4
"BU0": [
5
"Owl_project_pictures\Uncommon\Crested Owl\_crested_base.PNG",
6
"Owl_project_pictures\Uncommon\Crested Owl\_crested_bonus1.PNG",
7
]
8
}
9
10
11
Or put them as raw strings r"..."
:
JavaScript
1
9
1
2
"BU0": [
3
r"Owl_project_picturesUncommonCrested Owl_crested_base.PNG",
4
r"Owl_project_picturesUncommonCrested Owl_crested_bonus1.PNG",
5
]
6
}
7
8
9