我有一個drawingnumbers
的列表,我試圖拆分這些字符串,然後附加到一些列表。遍歷列表 - 拆分字符串
我希望結束了一些列表,其中包含每個相關的原始字符串片。
當時我的定義是遍歷列表,但覆蓋變量,而不是追加它們。因此,我爲每個變量都有一個條目,這些條目對應於列表的最終條目。
任何人都可以請幫忙嗎?
# drawingnumber split
drawingnumber = ["AAA601-XXX-A-L00-1028-DR-GA-200-001",
"AAA601-XXX-A-L10-1028-DR-GA-200-001",
"AAA601-XXX-A-L00-1029-DR-GA-200-001",
"AAA601-XXX-A-L00-1029-DR-GA-200-XXX"]
building = []
buildinglist = []
originator = []
discipline = []
level = []
scope = []
drawingtype = []
drawingsubtype = []
numbera = []
numberb = []
for i in drawingnumber:
building, originator, discipline, level, scope, \
drawingtype,drawingsubtype, numbera, numberb = i.split("-")
print("building:", building)
print("originator: ", originator)
print("discipline: ", discipline)
print("level: ", level)
print("scope: ", scope)
print("drawingtype: ", drawingtype)
print("drawingsubtype", drawingsubtype)
print("drawingident", numbera, "-", numberb)
打我吧,upvoted – Mureinik
完美 - 謝謝大家。 – Jup
@Jup:如果答案有幫助,考慮upvoting /接受它(左邊的綠色勾號)。 – Jan