大侠来帮忙看看。数据转换遇到TypeError: not all arguments converted during string formatting

# -*- coding: utf-8 -*-

sj='C:\\Users\\wt271\\Desktop\\jc\\passenger.txt' 
sa=[]
with open(sj) as b:
    sjj=b.read()
def s(ss,n):
    
    return [ss.append(sjj[i]) for i in sjj if i%n==0]
s(sa,3)    
    
print(sa)

cmd运行后如下

C:\Users\wt271>python C:\Users\wt271\Desktop\sj.py

Traceback (most recent call last):

  File "C:\Users\wt271\Desktop\sj.py", line 10, in <module>

    s(sa,3)

  File "C:\Users\wt271\Desktop\sj.py", line 9, in s

    return [ss.append(sjj[i]) for i in sjj if i%n==0]

  File "C:\Users\wt271\Desktop\sj.py", line 9, in <listcomp>

    return [ss.append(sjj[i]) for i in sjj if i%n==0]

TypeError: not all arguments converted during string formatting


无无法师
浏览 2079回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python