打开/试图读取文件 [英] Opening/Attempting to Read a file

查看:141
本文介绍了打开/试图读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

  ins = open() 
array = []
for line in in:
array.append(line)
ins.close()

它给我一个打开的错误:

<$ p (Ctrl + F1)



未解析的引用'open'less ...这个检查检测应该解决的名字,但是不要。由于动态调度和鸭子打字,这是有限的但有用的情况下可能的。顶级和类级别的项目比实例项目更受支持。


任何人都可以解释我做错了什么吗?
谢谢

解决方案

这是PyCharm中的一个已知问题,当它无法更新解释器的缓存时。如果你安装一个新的解释器,更新软件包等等,它会经常发生。

你可以在

如果它真的打扰你,你可以打击 ALT + ENTER 然后点击忽略未解决的参考

I tried to simply read and store the contents of a text file into an array, but:

ins = open( "file.txt", "r" )
array = []
for line in ins:
    array.append( line )
ins.close()

It gives me an error for "open":

Unresolved reference 'open' less... (Ctrl+F1) 

This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.

Can anyone explain what I'm doing wrong? Thanks

解决方案

This is a known issue in PyCharm, when it fails to update its cache of the interpreter. It happens most often if you install a new interpreter, update packages, etc.

You can search for this and related issues at the pycharm bug tracker

Its a temporary problem and will resolve itself. Keep an eye on the bottom right of the PyCharm window where it displays notifications (next to the icon of the guy in the hat). Click on this and the Event Log will have some messages for you.

If its really bothering you, you can hit ALT+ENTER and click "Ignore unresolved reference open"

这篇关于打开/试图读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆