Python str.strip() with regex filtering unexpected characters

前端 未结 6 822
广开言路
广开言路 2020-12-19 22:58

I\'m running into an issue that I hope is simple, however I\'ve run into a wall trying to figure it out. I\'m attempting to strip the DateTime timestamp from the beginning

6条回答
  •  伪装坚强ぢ
    2020-12-19 23:32

    As others have pointed out, you are using strip incorrectly. Instead, since you already have matching working, slice off the number of characters from the start of the string.

    result = line[:len(a.group())]
    print(result)
    # prints ' testc'
    

提交回复
热议问题