【问题标题】:Writing a text file in local host using python使用python在本地主机中编写文本文件
【发布时间】:2016-07-21 14:40:46
【问题描述】:

我已经使用 xampp 创建了一个本地主机服务器。我的目标是将值写入该服务器中的文本文件。我已经使用 python 使用 urllib.urlopen() 函数从 localhost 中的文件中读取值。请帮我将值写入文件

【问题讨论】:

  • 请展示您已经尝试过的内容(代码示例等)

标签: python xampp urllib


【解决方案1】:

如下尝试

f = open('file_name.txt','w')
f.write('Your message here\n') 
f.close()

【讨论】:

  • 这将写入本地文件....但我需要在“169.254.123.xxx/file_name.txt”位置打开一个文件,即。在本地服务器中
  • 修改文件路径如下f = open('/opt/lampp/htdocs/file_name.txt','w')
  • 它只搜索本地计算机中的文件而不是服务器上的文件
  • 服务器也可以写
猜你喜欢
  • 2017-07-08
  • 1970-01-01
  • 1970-01-01
  • 2013-11-27
  • 2022-10-14
  • 2013-04-07
  • 1970-01-01
  • 2014-03-13
  • 2016-10-15
相关资源
最近更新 更多