我想要一个文件,并创建一个单独的文件,其中包含整数和字符串的文件列表,但我收到此错误TypeError: integer argument expected, got 'str'
。为什么?接收类型错误:整数参数预计得到'str'
def main():
#open files allstar, playoffs, and regular season and create list by lines
with open("C:\\Users\\wittn\\OneDrive\\Documents\\Project\\databasebasketball20_1\\player_regular_season.txt", "r") as reg_season:
lst = list()
for list_lines in reg_season :
line = reg_season.readlines(list_lines.strip())
words = line.split (",")
lst = [words]
print (lst)
main()
欢迎堆栈溢出。也许你可以解释你认为你的程序的每一行都在做什么。另外,请务必提及哪一行会引发异常。你的调试器或Python解释器应该已经告诉你这些信息,并且它是你的问题中包含的关键信息。 –
@RobKennedy对,我读的代码有点太快 – Julien