我在按空格解析String2时遇到问题。思想?在
String1 = "THIS IS STRING1 18-23-80-18"
String2 = "THIS IS STRING2 7-A-4, 4-93-P"
Split1 = String1.rsplit(" ",2)
Output1 = "18-23-80-18" #This Works fine
Split2 = String2.????? # Not sure what to do here
Output2 = "7-A-4, 4-93-P" #How do I Ignore the first space from the right?
澄清:
*表示我试图忽略的空间,%表示我要查找的空间。在
^{pr2}$谢谢。在
如果您有兴趣在左三个空格处拆分字符串,而忽略右侧的所有其他字符串,则在之后:
一般的方法是在整个字符串上拆分空格,然后只从所需的范围中进行选择。然后用空格连接该范围。在
^{pr2}$使用正则表达式拆分字符串:
相关问题 更多 >
编程相关推荐