2013-08-28 30 views
0

当使用谷歌路线api并将选项设置为true时,某些建议的路线会超过公园。其他人是否已经观察到这种行为?以下是我打的网址,谷歌路线api - 一些备选路线经过公园

http://maps.googleapis.com/maps/api/directions/json?origin=37.557139,-121.975332&destination=37.539156,-121.923666&&alternatives=true&sensor=false

它返回下列3条备选路线JSON响应,

{ 
    "routes" : [ 
     { 
     "bounds" : { 
      "northeast" : { 
       "lat" : 37.56534449999999, 
       "lng" : -121.923525 
      }, 
      "southwest" : { 
       "lat" : 37.5392255, 
       "lng" : -121.9749241 
      } 
     }, 
     "copyrights" : "Map data ©2013 Google", 
     "legs" : [ 
      { 
       "distance" : { 
        "text" : "3.7 mi", 
        "value" : 6020 
       }, 
       "duration" : { 
        "text" : "9 mins", 
        "value" : 531 
       }, 
       "end_address" : "42701-42753 Mission Boulevard, Fremont, CA 94539, USA", 
       "end_location" : { 
        "lat" : 37.5392255, 
        "lng" : -121.923525 
       }, 
       "start_address" : "Fremont BART Station, Fremont, CA 94536, USA", 
       "start_location" : { 
        "lat" : 37.5576351, 
        "lng" : -121.9749241 
       }, 
       "steps" : [ 
        { 
        "distance" : { 
         "text" : "400 ft", 
         "value" : 122 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 50 
        }, 
        "end_location" : { 
         "lat" : 37.5570393, 
         "lng" : -121.9737687 
        }, 
        "html_instructions" : "Head \u003cb\u003esoutheast\u003c/b\u003e toward \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "polyline" : { 
         "points" : "[email protected]`A{BJY" 
        }, 
        "start_location" : { 
         "lat" : 37.5576351, 
         "lng" : -121.9749241 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.9 mi", 
         "value" : 1406 
        }, 
        "duration" : { 
         "text" : "2 mins", 
         "value" : 90 
        }, 
        "end_location" : { 
         "lat" : 37.5653107, 
         "lng" : -121.9618013 
        }, 
        "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "maneuver" : "turn-left", 
        "polyline" : { 
         "points" : "ojfdF`_ngVUQQMqAaA]][email protected]@US][email protected]}@[email protected]{B}BkEqAgCsDsH][email protected]_A{[email protected]@{@" 
        }, 
        "start_location" : { 
         "lat" : 37.5570393, 
         "lng" : -121.9737687 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "2.8 mi", 
         "value" : 4492 
        }, 
        "duration" : { 
         "text" : "7 mins", 
         "value" : 391 
        }, 
        "end_location" : { 
         "lat" : 37.5392255, 
         "lng" : -121.923525 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eMission Blvd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e", 
        "maneuver" : "turn-right", 
        "polyline" : { 
         "points" : "e~gdFftkgVE]?G?G?EBIBM~JwIlAgA`[email protected]@zA}AZ[dDmGxHuNxAoCP][email protected][email protected]@aBzAsCzIsO|AsCdGqKbBuCN][email protected]@}[email protected]}[email protected]@[email protected]@[email protected]`@{@zAaD\\[email protected]@[email protected]_LpG{M`[email protected]@[email protected][[email protected]@@[email protected]{@[email protected]@" 
        }, 
        "start_location" : { 
         "lat" : 37.5653107, 
         "lng" : -121.9618013 
        }, 
        "travel_mode" : "DRIVING" 
        } 
       ], 
       "via_waypoint" : [] 
      } 
     ], 
     "overview_polyline" : { 
      "points" : "[email protected]@{@{@][email protected][email protected]?MFWlM_L`EeDnBiB~B_CZ[[email protected]|CsG|[email protected]@[email protected]@`@[email protected]|[email protected]" 
     }, 
     "summary" : "Mission Blvd", 
     "warnings" : [], 
     "waypoint_order" : [] 
     }, 
     { 
     "bounds" : { 
      "northeast" : { 
       "lat" : 37.5576351, 
       "lng" : -121.923525 
      }, 
      "southwest" : { 
       "lat" : 37.5311789, 
       "lng" : -121.977954 
      } 
     }, 
     "copyrights" : "Map data ©2013 Google", 
     "legs" : [ 
      { 
       "distance" : { 
        "text" : "4.9 mi", 
        "value" : 7824 
       }, 
       "duration" : { 
        "text" : "11 mins", 
        "value" : 653 
       }, 
       "end_address" : "42701-42753 Mission Boulevard, Fremont, CA 94539, USA", 
       "end_location" : { 
        "lat" : 37.5392255, 
        "lng" : -121.923525 
       }, 
       "start_address" : "Fremont BART Station, Fremont, CA 94536, USA", 
       "start_location" : { 
        "lat" : 37.5576351, 
        "lng" : -121.9749241 
       }, 
       "steps" : [ 
        { 
        "distance" : { 
         "text" : "354 ft", 
         "value" : 108 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 16 
        }, 
        "end_location" : { 
         "lat" : 37.5571031, 
         "lng" : -121.9739004 
        }, 
        "html_instructions" : "Head \u003cb\u003esoutheast\u003c/b\u003e toward \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "polyline" : { 
         "points" : "[email protected]`A{B" 
        }, 
        "start_location" : { 
         "lat" : 37.5576351, 
         "lng" : -121.9749241 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.4 mi", 
         "value" : 683 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 74 
        }, 
        "end_location" : { 
         "lat" : 37.5518666, 
         "lng" : -121.977954 
        }, 
        "html_instructions" : "Take the 1st \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "polyline" : { 
         "points" : "{jfdFz_ngVXRzB|A`@[email protected]`@XDBRNHHVR`[email protected]@[email protected]@VRzAdAVR" 
        }, 
        "start_location" : { 
         "lat" : 37.5571031, 
         "lng" : -121.9739004 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.3 mi", 
         "value" : 507 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 66 
        }, 
        "end_location" : { 
         "lat" : 37.5493906, 
         "lng" : -121.9731305 
        }, 
        "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003ePaseo Padre Pkwy\u003c/b\u003e", 
        "maneuver" : "turn-left", 
        "polyline" : { 
         "points" : "[email protected]@[email protected]|AqD|AwDpA}CfBoE" 
        }, 
        "start_location" : { 
         "lat" : 37.5518666, 
         "lng" : -121.977954 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "2.7 mi", 
         "value" : 4408 
        }, 
        "duration" : { 
         "text" : "6 mins", 
         "value" : 330 
        }, 
        "end_location" : { 
         "lat" : 37.5316415, 
         "lng" : -121.9341935 
        }, 
        "html_instructions" : "Continue straight to stay on \u003cb\u003ePaseo Padre Pkwy\u003c/b\u003e", 
        "maneuver" : "straight", 
        "polyline" : { 
         "points" : "uzddF`{[email protected]@[email protected][email protected]@[email protected]@}@[email protected]@[email protected][email protected]_A^[email protected]@aAP[T][email protected]@V{@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]}@aA{[email protected]@[email protected]?EL{@[email protected]@[email protected]@iA^[email protected]\\[email protected]@[email protected]@_B\\[email protected]@{@[email protected]@[email protected]{AT}[email protected][email protected]@[email protected]@[email protected]@PWPO`@[TMVKZI\\[email protected][email protected]|@[email protected]@[email protected][email protected]}@[email protected]@[email protected]@CFMJ[\\_A`@[email protected]@\\gAJQ^[email protected]@[email protected]@" 
        }, 
        "start_location" : { 
         "lat" : 37.5493906, 
         "lng" : -121.9731305 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.2 mi", 
         "value" : 396 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 46 
        }, 
        "end_location" : { 
         "lat" : 37.5311789, 
         "lng" : -121.9386345 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eWashington Blvd\u003c/b\u003e", 
        "maneuver" : "turn-right", 
        "polyline" : { 
         "points" : "[email protected]`BB`@NtDLvBLnC" 
        }, 
        "start_location" : { 
         "lat" : 37.5316415, 
         "lng" : -121.9341935 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.8 mi", 
         "value" : 1365 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 82 
        }, 
        "end_location" : { 
         "lat" : 37.5385712, 
         "lng" : -121.927027 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e to merge onto \u003cb\u003eI-680 N\u003c/b\u003e toward \u003cb\u003eSacramento\u003c/b\u003e", 
        "polyline" : { 
         "points" : "{[email protected][[email protected]@[email protected]@[email protected][email protected]@[email protected]@][email protected]@[email protected][[email protected]}CoCgG" 
        }, 
        "start_location" : { 
         "lat" : 37.5311789, 
         "lng" : -121.9386345 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.2 mi", 
         "value" : 312 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 21 
        }, 
        "end_location" : { 
         "lat" : 37.5395679, 
         "lng" : -121.9237934 
        }, 
        "html_instructions" : "Take the \u003cb\u003eMission Blvd\u003c/b\u003e exit toward \u003cb\u003eCalifornia 238\u003c/b\u003e", 
        "maneuver" : "ramp-right", 
        "polyline" : { 
         "points" : "awbdF|[email protected]@[email protected]@[email protected]@[email protected]" 
        }, 
        "start_location" : { 
         "lat" : 37.5385712, 
         "lng" : -121.927027 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "148 ft", 
         "value" : 45 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 18 
        }, 
        "end_location" : { 
         "lat" : 37.5392255, 
         "lng" : -121.923525 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eMission Blvd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e", 
        "maneuver" : "turn-right", 
        "polyline" : { 
         "points" : "i}[email protected]" 
        }, 
        "start_location" : { 
         "lat" : 37.5395679, 
         "lng" : -121.9237934 
        }, 
        "travel_mode" : "DRIVING" 
        } 
       ], 
       "via_waypoint" : [ 
        { 
        "location" : { 
         "lat" : 37.542142, 
         "lng" : -121.9527896 
        }, 
        "step_index" : 3, 
        "step_interpolation" : 0.4860572290564731 
        } 
       ] 
      } 
     ], 
     "overview_polyline" : { 
      "points" : "[email protected]`DxBkFzDiJxDmJvEeLxB_FtAmDdAuBtB}[email protected][[email protected]@gB\\[email protected][email protected]@FkAZoBbA{[email protected]@oB\\[email protected]@[email protected]@[email protected]@[email protected]\\[email protected][email protected]|@[email protected]|[email protected]@[email protected][email protected]}@[email protected]@[email protected]{[email protected]@[email protected]@[email protected]@[email protected]@LbC\\[email protected][email protected][email protected]@[email protected][email protected]@[email protected][email protected]]}@[email protected]_AoB][email protected]{@[email protected]" 
     }, 
     "summary" : "Paseo Padre Pkwy", 
     "warnings" : [], 
     "waypoint_order" : [] 
     }, 
     { 
     "bounds" : { 
      "northeast" : { 
       "lat" : 37.5576351, 
       "lng" : -121.923525 
      }, 
      "southwest" : { 
       "lat" : 37.5392255, 
       "lng" : -121.977954 
      } 
     }, 
     "copyrights" : "Map data ©2013 Google", 
     "legs" : [ 
      { 
       "distance" : { 
        "text" : "4.3 mi", 
        "value" : 6957 
       }, 
       "duration" : { 
        "text" : "12 mins", 
        "value" : 697 
       }, 
       "end_address" : "42701-42753 Mission Boulevard, Fremont, CA 94539, USA", 
       "end_location" : { 
        "lat" : 37.5392255, 
        "lng" : -121.923525 
       }, 
       "start_address" : "Fremont BART Station, Fremont, CA 94536, USA", 
       "start_location" : { 
        "lat" : 37.5576351, 
        "lng" : -121.9749241 
       }, 
       "steps" : [ 
        { 
        "distance" : { 
         "text" : "354 ft", 
         "value" : 108 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 16 
        }, 
        "end_location" : { 
         "lat" : 37.5571031, 
         "lng" : -121.9739004 
        }, 
        "html_instructions" : "Head \u003cb\u003esoutheast\u003c/b\u003e toward \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "polyline" : { 
         "points" : "[email protected]`A{B" 
        }, 
        "start_location" : { 
         "lat" : 37.5576351, 
         "lng" : -121.9749241 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.4 mi", 
         "value" : 683 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 74 
        }, 
        "end_location" : { 
         "lat" : 37.5518666, 
         "lng" : -121.977954 
        }, 
        "html_instructions" : "Take the 1st \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "polyline" : { 
         "points" : "{jfdFz_ngVXRzB|A`@[email protected]`@XDBRNHHVR`[email protected]@[email protected]@VRzAdAVR" 
        }, 
        "start_location" : { 
         "lat" : 37.5571031, 
         "lng" : -121.9739004 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.3 mi", 
         "value" : 507 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 66 
        }, 
        "end_location" : { 
         "lat" : 37.5493906, 
         "lng" : -121.9731305 
        }, 
        "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003ePaseo Padre Pkwy\u003c/b\u003e", 
        "maneuver" : "turn-left", 
        "polyline" : { 
         "points" : "[email protected]@[email protected]|AqD|AwDpA}CfBoE" 
        }, 
        "start_location" : { 
         "lat" : 37.5518666, 
         "lng" : -121.977954 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "1.6 mi", 
         "value" : 2600 
        }, 
        "duration" : { 
         "text" : "3 mins", 
         "value" : 191 
        }, 
        "end_location" : { 
         "lat" : 37.5411851, 
         "lng" : -121.9481001 
        }, 
        "html_instructions" : "Continue straight to stay on \u003cb\u003ePaseo Padre Pkwy\u003c/b\u003e", 
        "maneuver" : "straight", 
        "polyline" : { 
         "points" : "uzddF`{[email protected]@[email protected][email protected]@[email protected]@}@[email protected]@[email protected][email protected]_A^[email protected]@aAP[T][email protected]@V{@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]}@aA{[email protected]@[email protected]?EL{@[email protected]@[email protected]@iA^[email protected]\\[email protected]@NW" 
        }, 
        "start_location" : { 
         "lat" : 37.5493906, 
         "lng" : -121.9731305 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.7 mi", 
         "value" : 1195 
        }, 
        "duration" : { 
         "text" : "2 mins", 
         "value" : 106 
        }, 
        "end_location" : { 
         "lat" : 37.54969699999999, 
         "lng" : -121.9398308 
        }, 
        "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eDriscoll Rd\u003c/b\u003e", 
        "maneuver" : "turn-left", 
        "polyline" : { 
         "points" : "mgcdFr~hgVOS]YeEsD{BmB_BsAuEoEwAsAuB{[email protected]@MMaBeBsBsBwBsBwAwAoCsCkDgD" 
        }, 
        "start_location" : { 
         "lat" : 37.5411851, 
         "lng" : -121.9481001 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "1.2 mi", 
         "value" : 1864 
        }, 
        "duration" : { 
         "text" : "4 mins", 
         "value" : 244 
        }, 
        "end_location" : { 
         "lat" : 37.5392255, 
         "lng" : -121.923525 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eMission Blvd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e", 
        "maneuver" : "turn-right", 
        "polyline" : { 
         "points" : "s|ddF|[email protected]@}[email protected]}[email protected]@[email protected]@[email protected]`@{@zAaD\\[email protected]@[email protected]_LpG{M`[email protected]@[email protected][[email protected]@@[email protected]{@[email protected]@" 
        }, 
        "start_location" : { 
         "lat" : 37.54969699999999, 
         "lng" : -121.9398308 
        }, 
        "travel_mode" : "DRIVING" 
        } 
       ], 
       "via_waypoint" : [ 
        { 
        "location" : { 
         "lat" : 37.5448008, 
         "lng" : -121.9447476 
        }, 
        "step_index" : 4, 
        "step_interpolation" : 0.4176798920642508 
        } 
       ] 
      } 
     ], 
     "overview_polyline" : { 
      "points" : "[email protected]`DxBkFzDiJxDmJvEeLxB_FtAmDdAuBtB}[email protected][[email protected]@gB\\[email protected][email protected]@FkAZoBbA{[email protected]{EaEmHcHoCuCkGoGoEkEoCsCkDgDdHuNhB{DpC}FfEqI|B}[email protected]@cA`[email protected][email protected]~CsBtAcA" 
     }, 
     "summary" : "Paseo Padre Pkwy and Mission Blvd", 
     "warnings" : [], 
     "waypoint_order" : [] 
     } 
    ], 
    "status" : "OK" 
} 

我使用overview_polyline每个路由对象在JavaScript中看地图中的多段线。我将使用来自后端python应用程序的API,并且只有在这种情况下,JavaScript才会进行交叉检查,以防万一您想知道为什么我不使用JavaScript API。

<html> 
<head> 
<title>Test</title> 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?libraries=geometry&amp;sensor=false"></script> 
<style type="text/css"> 
    #map {width:670px;height:600px;} 
</style> 
<script type='text/javascript'> 
function initialize() { 
    var myLatlng = new google.maps.LatLng(37.557139,-121.975332); 
    var myOptions = { 
     zoom: 12, 
     center: myLatlng, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    } 
    var map = new google.maps.Map(document.getElementById("map"), myOptions); 

    // between first two stops - alternate 2 
    var polyLineStr = "[email protected]`DxBkFzDiJxDmJvEeLxB_FtAmDdAuBtB}[email protected][[email protected]@gB\[email protected][email protected]@FkAZoBbA{[email protected]mE{EaEmHcHoCuCkGoGoEkEoCsCkDgDdHuNhB{DpC}FfEqI|B}[email protected]@cA`[email protected][email protected]~CsBtAcA"; 

    var decodedPath = google.maps.geometry.encoding.decodePath(polyLineStr); 
    var decodedLevels = decodeLevels("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); 

    var setRegion = new google.maps.Polyline({ 
     path: decodedPath, 
     levels: decodedLevels, 
     strokeColor: "#FF0000", 
     strokeOpacity: 1.0, 
     strokeWeight: 2, 
     map: map 
    }); 
} 

function decodeLevels(encodedLevelsString) { 
    var decodedLevels = []; 

    for (var i = 0; i < encodedLevelsString.length; ++i) { 
     var level = encodedLevelsString.charCodeAt(i) - 63; 
     decodedLevels.push(level); 
    } 
    return decodedLevels; 
} 
</script> 
</head> 
<body onload="initialize()"> 
<div id="map"></div> 
</body> 
</html> 

我想我做错了什么 - 但不知道是什么。任何帮助,将不胜感激。这jsfiddle link显示的行为。

+0

您是否尝试过使用人类Web界面进行等效查询以查看您是否得到相同的结果?如果你这样做,问题出在Google的数据上,你可以做的事情不多,只是抱怨他们。如果它做了不同的事情,那么你可以试着找出不同的东西并解决它。 – abarnert

+2

您在编码折线中有非反斜杠,导致路径出错。 – geocodezip

+0

此外,结果似乎有一个更大的问题,而不是它如何到达目的地 - 目的地远不及你要求的地方。 – abarnert

回答

0

这只是您测试代码的一个工件。您的字符串字面polyLineStr

var polyLineStr = "[email protected]`DxBkFzDiJxDmJvEeLxB_FtAmDdAuBtB}[email protected][[email protected]@gB\[email protected][email protected]@FkAZoBbA{[email protected]{EaEmHcHoCuCkGoGoEkEoCsCkDgDdHuNhB{DpC}FfEqI|B}[email protected]@cA`[email protected][email protected]~CsBtAcA"; 

...在它的中间一个转义'\e'。据推测,无论你复制并粘贴它,它只是实际打印的字符串,并且只要在其周围添加引号就可以将它转换为JS文字。但在JS文字中,'\e'表示e,所以反斜杠丢失,导致整个路径出错。

解决这个特殊的问题是只是为了逃避它:

var polyLineStr = "[email protected]`DxBkFzDiJxDmJvEeLxB_FtAmDdAuBtB}[email protected][[email protected]@gB\\[email protected][email protected]@FkAZoBbA{[email protected]{EaEmHcHoCuCkGoGoEkEoCsCkDgDdHuNhB{DpC}FfEqI|B}[email protected]@cA`[email protected][email protected]~CsBtAcA"; 

那一个个字符改变你拨弄使得它给出正确的结果。

在你的实际代码中,这个问题可能甚至不会到达,因为你的源代码中没有路径作为文字(或者尝试使用字符串值来产生和评估字符串文字) ;你只需从JSON中获取它们就可以了。

(有趣的是,如果你想在Python中进行了测试,你就不会注意到了这个问题,因为'\e'将解析为\e,而不是仅仅e反正...这将是更加神秘,因为它止跌直到你运行了一个测试,例如,中间有一个'\n'的测试。)