a = "sdfg" b = "ag" c = "gsrg" li = [] li += a, li += b, li += c, print(li) #[‘sdfg‘, ‘ag‘, ‘gsrg‘]
句尾没有逗号
a = "sdfg" b = "ag" c = "gsrg" li = [] li += a li += b li += c print(li) #[‘s‘, ‘d‘, ‘f‘, ‘g‘, ‘a‘, ‘g‘, ‘g‘, ‘s‘, ‘r‘, ‘g‘]
或者可以直接用append(),避免逗号的问题
原文地址:https://www.cnblogs.com/imageSet/p/8428414.html
时间: 2024-10-10 22:11:17