一个简单的包装类,用于简单地读取/遍历、写入和追加文件。

filework的Python项目详细描述


这个包可以在https://github.com/aescwork/filework找到。

在github存储库中有sphinx生成的文档:主页面是docs/index.html。文档中包括一个用法 文件(docs/usage.html),它提供了一个关于方法如何工作以及如何调用它们的简单且希望有用的解释。

FileWork是一个用于简化文件工作的类

大多数处理文件的繁琐代码都包含在类中,因此调用代码不需要费心处理它。

文件工作对象可以:

  1. 创建文件
  2. 写入文件
  3. 将内容附加到文件
  4. 读取文件的全部内容
  5. 一次读取一行文件
  6. 打开或关闭与文件的连接
  7. 删除文件

此模块最初是为waxtablet应用程序创建的。

此包安装完成后,尝试使用该模块可能会导致以下错误:“importerror:没有名为filework的模块” 或其他错误信息。

这可能表示python解释器可能无法找到模块。在这种情况下, 建议如下:

On Linux:

Locate where the package was installed. In the terminal, navigate to the root directory and execute the following command:

sudo find . -name filework.py

这应该给出filework.py文件的路径。 创建一个名为“local_python.sh”的文件,并将以下文本放入其中:

PYTHONPATH=”/usr/local/lib/python*.*/dist-packages/filework/”:”${PYTHONPATH}” export PYTHONPATH

要使模块对所有用户都可用,请将此文件放在/etc/profile.d中,然后放置一行来执行 文件位于.bashrc中的某个位置,或单个(非根)用户终端中的其他bash配置文件之一:

. /etc/profile.d/local_python.sh

这将导致python解释器在模块中找到filework.py文件。

在MS Windows上:

The following was tested on a machine running Windows 10.

(This assumes that Python is installed on the machine.)

Locate where the package was installed. On Windows 10, Look for the Python folder. Its usually right under the C: drive. The name of the folder probably has the version number in it as well, like “Python27”. Look for the filework folder: it should be in “Lib” and then “site-packages” folder.

Open up the System Properties Panel. (You can find this by clicking on the “Settings” icon and entering “Environment Variables” in the search bar. When the panel comes up, Click the “Environment Variables” button. Under “System variables”, click “New” and type in the full path to the filework folder.

Test this by opening the command line application and starting the Python interpreter (type the command “python” and press enter). Now try to import the module and instantiate a filework object. Type the following:

>>> import filework
>>> sg = filework.SQLiteMgr()
>>> sg.result

If everything went well, ‘None’ should print out on the screen. If there was an “ImportError” or any other error, try importing the module again and test as follows:

>>> import filework.filework as filework
>>> sg = filework.FileWork()
>>> sg.result

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JAVAutil。整数java的扫描器键盘输入   java通知运行后立即崩溃   java如何在一个只能由类修改而不能由其实例修改的类中生成静态变量?   数据库Java字段猜测   返回值周围的java括号为什么?   java Android更新通讯录中的联系人   一个消费者正在读取数据   java是否可以通过编程方式为蓝牙配对设置pin?   java Spring引导和buildResponseEntity()   java为什么序列化可以在没有实现可序列化的情况下工作   Java同步无助于相互排斥   twitter Java Twitter4J未在推文下显示源标签   为什么Javasocket不支持中断处理?