Python: Convert tuple to comma separated String

后端 未结 3 753
谎友^
谎友^ 2021-01-13 04:29
import MySQLdb

db = MySQLdb.connect(\"localhost\",\"root\",\"password\",\"database\")
cursor = db.cursor()
cursor.execute(\"SELECT id FROM some_table\")
u_data = cu         


        
3条回答
  •  感情败类
    2021-01-13 05:06

    string = ((1320088L,),)
    print(','.join(map(str, list(sum(string, ())))))
    string = ((1320088L, 1232121L), (1320088L,),)
    print(','.join(map(str, list(sum(string, ())))))
    

    Output:

    1320088
    1320088,1232121,1320088
    

提交回复
热议问题