【发布时间】:2011-07-12 14:13:38
【问题描述】:
这个问题可能很简单,但我想不通 -
我有以下值:['2000']['09']['22']
我想要以下内容:20000922 或 '20000922'
代码
def transdatename(d):
year = re.findall('\d\d\d\d', str(d))
premonth = re.findall('[A-Z][a-z]{2,9}', str(d))
month = replace_all(str(premonth), reps)
daypre = re.findall('\d{1,2},', str(d))
day = re.sub(',','', str(daypre))
fulldate = str(year)+str(month)+str(day)
return fulldate
示例数据
输入: ['\n2000 年 9 月 23 日']
预期输出: '20000922'
【问题讨论】:
-
['2000']['09']['22'] - 它是什么?一个字符串?一份清单?
-
@user831880 我们很难提供帮助,因为我们不确定您所说的
['2000']['09']['22']是什么意思。您能否编辑您的问题以包含来自 Python 解释器或 .py 文件的一些尝试的代码? -
我不确定它是什么!我正在尝试连接 3 个值,我认为这应该会导致一个长字符串,但它不起作用。我已将代码添加到原始帖子中。
-
请给我们输入和预期输出
-
我在上面添加了示例输入和输出。谢谢!!
标签: python concatenation