第32044题 单选题
执行以下Python代码,最终的输出结果是?
my_str = "apple,banana,orange"
# 步骤1:将字符串按逗号分割为列表
fruit_list = my_str.split(",")
# 步骤2:将列表用竖线|拼接为新字符串
new_str = "|".join(fruit_list)
# 步骤3:将新字符串前7位转为列表
res = list(new_str[:7])
print(res)
A

['a', 'p', 'p', 'l', 'e', '|', 'b']

B

['apple', '|', 'banana']

C

['a', 'p', 'p', 'l', 'e', ',', 'b']

D

['apple|ban']

程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析