新增表頭,不是新增索引

2021-10-09 15:25:31 字數 1162 閱讀 4835

list1 = df.x2

file

="c:/users/administrator/desktop/連續3天 0商機.csv"

with

open

(file

,'w'

, newline='')

as f:

fieldnames =

['門店名稱'

,'日期'

,'人數'

,'商機量'

,'檢視次數'

,'二手帶看量'

,'人均商機量'

,'人均檢視次數'

] writer = csv.dictwriter(f,fieldnames=fieldnames)

writer.writeheader(

)for i in

range

(len

(list1)-2

):if list1[i]

+ list1[i +1]

+ list1[i +2]

==0:# if list1[i] > 3 and list1[i + 1] > 3 and list1[i + 2] > 3:

for j in

range(2

):index =

[str

(df.name[i + j]),

str(df.date[i + j]),

str(df.x1[i + j]),

str(df.x2[i + j]),

str(df.x3[i + j]),

str(df.x4[i + j]),

str(df.y1[i + j]),

str(df.y2[i + j]),

"\n"

]print

(index)

str1 =

",".join(index)

# 列表list 改為 字串str --文字 ,csv

# file = "c:/users/administrator/desktop/連續3天0商機try.csv"

# with open(file, 'a') as f:

f.write(str1)

mysql 新增索引

mysql索引原理 1.新增primary key 主鍵索引 mysql alter table table name add primary key column 2.新增unique 唯一索引 mysql alter table table name add unique column 3.新增...

mysql 新增索引

1.新增primary key 主鍵索引 語法 alter table 表名 add primary key 列名稱 mysql alter table table name add primary key column 2.新增unique 唯一索引 語法 alter table 表名 add u...

mysql alter 新增索引

1.新增主鍵索引 alter table table name add primary key column 2.新增唯一索引 alter table table name add unique column 3.新增全文索引 alter table table name add fulltext ...