assign(x,y) x是文件变量,y是字符串,所以 n'.txt' 是不行的,先把n转换为字符串类型st,里面是st+‘.txt' str(n,st); assign(input,st+'txt');若满意请采纳,O(∩_∩)O谢谢