cadastral map - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: cadastral map (/thread-15169.html) |
cadastral map - esther - Jan-06-2019 hello! Im trying to draw a map of annecy but I cant here's what Ive got for now and Ive already got a mistake ((executing lines 1 to 10 of "<tmp 1>") File "<tmp 1>", line 7 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape)which I dont understand please help import json import tkinter parcelles = [ ] for num in ["010", "019", "067", "112", "186", "213", "219"]: with open("C:\Users\esther\Downloads\cadastre/cadastre-74"+num+"-communes.json") as json_data: data_dict = json.load(json_data) for k in range(len(data_dict["features"])): parcelles.append(data_dict["features"] [k] ["geometry"] ["coordinates"]) RE: cadastral map - Gribouillis - Jan-06-2019 There is an error because \Uxxxx is used in literal strings to enter unicode characters that you can't type on the keyboard. Python complains because of "\Users". Use a raw string r"C:\Users\esther\Downloads\cadastre/cadastre-74" (note the leading 'r').
RE: cadastral map - esther - Jan-07-2019 (Jan-06-2019, 11:52 PM)Gribouillis Wrote: There is an error because \Uxxxx is used in literal strings to enter unicode characters that you can't type on the keyboard. Python complains because of "\Users". Use a raw string thank you gribouillis there is no more mistake
RE: cadastral map - buran - Jan-07-2019 Just for completeness, in addition to raw string as suggested by Gribouillis, you can escape the backslash (i.e. use double backslash "C:\\Users\\esther\\Downloads\\cadastre\\cadastre-74"+num+"-communes.json" or use forward-slash "C:/Users/esther/Downloads/cadastre/cadastre-74"+num+"-communes.json"
|