为了账号安全,请及时绑定邮箱和手机立即绑定

Python打开文件

Python打开文件

米脂 2021-03-02 09:18:44
我目前正在以python语言建立一个项目,该项目可以打开文本文档(.txt)。但是我遇到了一个问题。我尝试使用以下代码打开文档:f = open("music_data.txt","r")print(f)但这不起作用。它只是说:<_io.TextIOWrapper name='music_data.txt' mode='r' encoding='cp1252'>这似乎是打印包含文档的变量的标准方法,但是随后给出了错误消息:Traceback (most recent call last):File "\\bcs\StudentRedir2010$\StudentFiles\MyName\MyDocuments\Computing\Programming\Python\Music Program\program.py", line 45, in <module>mode()File "\\bcs\StudentRedir2010$\StudentFiles\MyName\MyDocuments\Computing\Programming\Python\Music Program\program.py", line 43, in modemode()TypeError: 'str' object is not callable而且我不知道为什么会这样。
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 608 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号