这个信息是什么意思?from:无法读取/var/mail/ex48(通过ex49学习Python)

2024-06-09 19:24:11 发布

您现在位置:Python中文网/ 问答频道 /正文

在ex49中,我们被告知使用以下命令调用在ex48中创建的lexicon.py文件。

当我尝试用以下命令导入词典文件时

    >>> from ex48 import lexicon

它返回以下内容:

    from: can't read /var/mail/ex48

我试过查这个。这是什么意思?文件放错地方了吗?


Tags: 文件frompyimport命令readvar地方
2条回答

您没有在Python shell中键入“from ex48 import lexicon”,而是在命令行中键入了它from”是列出邮件发件人的命令,因此是/var/mail位置。

从命令产生的不同错误消息可以看出这一点:

localhost-2:~ $ from ex48 import lexicon
from: can't read /var/mail/ex48
localhost-2:~ $ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ex48 import lexicon
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ex48

您需要将shebang添加到程序的第一行。放入#!/usr/bin/python或python bin所在的位置,程序将运行。

相关问题 更多 >