duanbozhong9689 2010-07-28 02:23
浏览 34
已采纳

Python - PHP共享MySQL服务器连接信息?

I have some MySQL database server information that needs to be shared between a Python backend and a PHP frontend.

What is the best way to go about storing the information in a manner wherein it can be read easily by Python and PHP?

I can always brute force it with a bunch of str.replace() calls in Python and hope it works if nobody has a solution, or I can just maintain two separate files, but it would be a bunch easier if I could do this automatically.

I assume it would be easiest to store the variables in PHP format directly and do conversions in Python, and I know there exist Python modules for serializing and unserializing PHP, but I haven't been able to get it all figured out.

Any help is appreciated!

  • 写回答

1条回答 默认 最新

  • doudou6719 2010-07-28 02:33
    关注

    Store the shared configuration in a plain text file, preferably in a standard format.

    You might consider yaml, ini, or json.

    I'm pretty sure both PHP and python can very trivially read and parse all three of those formats.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用三极管设计一个单管共射放大电路
  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架