程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

python增刪yaml文件裡一行內容

編輯:Python

Locations:
MAIN_0001: [-1.3401, -8.2084, 1.2036]
MAIN_0002: [-1.3918, -6.0548, 1.2036]
MAIN_0003: [-1.2194, -3.5139, 1.2036]
MAIN_0004: [-1.1109, -1.3228, 1.2036]
MAIN_0005: [-1.0324, 1.2392, 1.2036]
MAIN_0006: [-1.1030, 2.5668, 1.2036]
MAIN_0007: [-1.1669, 4.7799, 1.2036]
MAIN_0008: [-1.2177, 6.0613, 1.2036]
MAIN_0009: [-1.1781, 10.0640, 1.2036]
PICKING_0001: [-11.9054, -7.9195, 0.0100]
PICKING_0002: [-9.9039, -7.8358, 0.0100]
PICKING_0003: [-7.9513, -7.8522, 0.0100]
PICKING_0004: [-6.0331, -8.0235, 0.0100]
PICKING_0005: [-4.1481, -7.9870, 0.0100]
PICKING_0006: [-2.1453, -8.0850, 0.0100]
PICKING_0007: [-0.2846, -6.6251, 1.5708]
PICKING_0008: [-0.2846, -6.6251, 2.0344]
PICKING_0009: [-4.0708, -6.0565, 3.1416]
Route:

  • [PICKING_0001, PICKING_0002]
  • [PICKING_0002, PICKING_0003]
  • [PICKING_0003, PICKING_0004]
  • [PICKING_0004, PICKING_0005]
  • [PICKING_0005, PICKING_0006]
  • [PICKING_0007, PICKING_0008]
  • [PICKING_0009, PICKING_0010]
  • [PICKING_0010, PICKING_0011]
  • [PICKING_0011, PICKING_0012]
  • [PICKING_0012, PICKING_0013]
  • [PICKING_0013, PICKING_0014]
  • [PICKING_0015, PICKING_0016]
  • [PICKING_0016, PICKING_0017]
  • [PICKING_0017, PICKING_0018]
    如上面yaml文件,由兩部分組成:
    Locations:裡面記錄的是點位的名稱/坐標
    Route:裡面記錄的是點位間的路徑
    如何使用python腳本實現以下操作:
    一,python3 x.py locations_delete MAIN_0001
    刪除上面yaml文件中Locations裡面的 MAIN_0001: [-1.3401, -8.2084, 1.2036]這一行
    二,python3 x.py routes_delete PICKING_0001 PICKING_0002
    刪除上面yaml文件中,Route裡面的, - [PICKING_0001, PICKING_0002]
    三,二,python3 x.py routes_add PICKING_0001 PICKING_0002
    上面yaml文件中,Route裡面,添加, - [PICKING_0001, PICKING_0002]
    本人自學python,水平不高,想了很久暫未能實現,多謝幫助,不勝感激

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved