刚才练习的时候,报如下错误:

AttributeError: module 'fileinput' has no attribute 'input',后来Google参考这篇文章https://mail.python.org/pipermail/tutor/2005-June/039321.html发现原来文件名写成fileinput.py了,这样你导入的就不是fileinput这个模块了,而是你的程序,所以就报没有input属性,把程序文件名改成别的就可以了。

#!/usr/bin/env python
#coding=utf8
import fileinput
for line in fileinput.input("test",inplace=1):
    print(line,)
fileinput

相关文章:

  • 2022-12-23
  • 2021-12-04
  • 2021-05-26
  • 2021-09-30
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-09-16
猜你喜欢
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2021-10-12
相关资源
相似解决方案