def read(file):
f=open(file,'r') #读取文件
li=[]
for line in f:
s=''
for i in range(len(line.strip())): #strip()函数删除字符串末尾的“\n”
ch=line[i]
if ch==',':
flag=True
if ch>='0'and ch<='9'and flag:
s=s+ch
li.append(s)
f.close()
return li
def gl(s):
a=[]
for i in range(len(s)- 1):
x=s[i]
for j in range():
y=s[j]
return a
def maxgl(dic):
mt=0
for i in dic:
if dic[i]>mt:
return mt
dic={}
li=read('data.txt')#data.txt 是流水文件
for i in li:
if len(i)>1:
a=g1(i)
for j in a:
if j in dic:
dic[j]+=1
else:
dic[j]=1
mt=maxg1(dic)
for i in dic:
if
print('关联度最多的一组商品是: x'+i[0]+'和x'+i[1])