Is there a way to split the text of each input in an array to words with a separator? Example Input
tag_attribute = ['Content_ExportDate','Controller_SoftwareRevision','DataType_Owner']
With the separator as '_', the expected printed result:
Tag: Content
Attribute: Exportdate
Tag: Controller
Attribute: SoftwareRevision
Tag: DataType
Attribute: Owner
The '_' is just an example I can think of for a separator, but I can work with any of other symbols. I just need to find a way to have the input in an array as two separate inputs
You can use this example it will generate you the output that you want
for tag, att in [x.split("_") for x in tag_attribute]:
print(f"Tag: {tag}")
print(f"Attribute: {att}")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.