我有一堆的文件路徑:一旦定義的ID號,並使用它的每一個文件路徑
shapefile = "C:\\file\\path \\here\\this\\one\\is\\different\\2001_6W.shp"
place1 = "C:\\file\\path\\here\\place1_2001.shp"
place2 = "C:\\file\\path\\here\\place2_2001.shp"
place3 = "C:\\file\\path\\here\\place3_2001.shp"
我想,如果我可以定義數ID(2001),然後讓其在使用文件名如下:
ID = 2001
shapefile = "C:\\file\\path \\here\\this\\one\\is\\different\\ID_6W.shp"
place1 = "C:\\file\\path\\here\\place1_ID.shp"
place2 = "C:\\file\\path\\here\\place2_ID.shp"
place3 = "C:\\file\\path\\here\\place3_ID.shp
有沒有辦法做到這一點?我不確定我是否很好地解釋了我想要的內容。
您可以對此使用正則表達式 - 但爲什麼你想要?爲什麼不只是像「C:\\ file \\ path \\ here \\ place1 _」+ ID +「。shp」那樣追加字符串? – OneRaynyDay