简体   繁体   English

是否有可能多个用户使用python将数据写入文件(excel或文本)

[英]is it possible for multiple users to write data into a file (excel or text) using python

I am trying to get some info (which keeps changing) from different computers into a text file. 我正在尝试将来自不同计算机的一些信息(不断变化)转换为文本文件。 Is it possible to write using python file by creating a text or excel file. 是否可以通过创建文本或excel文件使用python文件编写。 This is how I am planning 1. The file sits on a common location accessible by all the computers. 这就是我的计划方式1.文件位于所有计算机都可以访问的公共位置。 2. The python script runs in each computer and updates the file in the common location 3. Whenever I open, I should see the information that is updated. 2. python脚本在每台计算机上运行,​​并在公共位置更新文件。3.每当我打开计算机时,都应该看到更新的信息。

Problems will arise when opening and saving files by multiple computers. 通过多台计算机打开和保存文件时会出现问题。

What happens when a computer opens a file, and saves data on top of another save? 当计算机打开文件并将数据保存到另一个保存顶部时,会发生什么情况?

The situation you described would be well suited to a database. 您描述的情况非常适合数据库。 A popular open-source and free database server is MySQL which can handle multiple connections and users reading and modifying the data using a language called SQL , and yes, python can connect to databases with this package. MySQL是一种流行的开源免费数据库服务器,它可以处理多个连接,并且用户可以使用称为SQL的语言来读取和修改数据,是的,python可以使用软件包连接到数据库。

And of course, you can export the database to a spreadsheet file to review on your computer. 当然,您可以将数据库导出到电子表格文件中以在计算机上进行检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM