【问题标题】:How to search for keywords in a txt-file and print full string out [duplicate]如何在 txt 文件中搜索关键字并打印出完整的字符串 [重复]
【发布时间】:2021-05-22 02:15:52
【问题描述】:

你好我正在使用python结合txt文件,想让我的代码搜索单词的一部分,就像我的txt文件看起来像这样=

'www.test.com/product/wings' , 'www.test1.com/product/chicken' , 'www.okay.com/product/burger' , 'www.Test23542.com/product/smoothie'

所以我想让我的代码打开文件并搜索“www.test1.com/product/”,它应该打印出完整的链接,包括像 = 'www.test1.com/product/ 这样的产品鸡'

我被卡住了,不知道该怎么做,所以我当前的代码不会真正有帮助,因为它只有一行。

【问题讨论】:

    标签: python list text txt


    【解决方案1】:

    这是example。使用open,然后readreadline 读取文件中的日期,然后使用str() methods 查找您需要的内容,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 2014-09-06
      • 1970-01-01
      • 2021-06-24
      相关资源
      最近更新 更多