【发布时间】:2018-02-11 06:19:25
【问题描述】:
我想在python中使用\作为分隔符来分割从输入中获得的字符串。我看到了一些要求将r 放在字符串之前的答案。在这种情况下我不知道该怎么做。
代码如下:
import re
dob = input("Please enter the string ")
-> Please enter the string : 11\15\1995
sep = re.split('\\',dob)
预期输出:
sep = ['11','15','1995']
【问题讨论】: