a={1:1,2:2,3:3} l = [str(k) for k in a.keys()] print ','.join(l)
首先构建一个key组成的list,字典a中的key时int类型,为了使用str的join()方法链接字符串,于是在构建list时须要使用str(k)python