Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我在一个hmd.txt文件中有许多句子,我想将每个句子按“分开”&引用;在整个文本文件的一段中。例如_Python - Fatal编程技术网

Python 我在一个hmd.txt文件中有许多句子,我想将每个句子按“分开”&引用;在整个文本文件的一段中。例如

Python 我在一个hmd.txt文件中有许多句子,我想将每个句子按“分开”&引用;在整个文本文件的一段中。例如,python,Python,“我无法决定这三款相机(以及它们的变体,索尼HX30和松下ZX20),因为对每款相机的许多评论都让它们听起来非常相似。因此,我出去买了(从接受退货的商家那里买的)这三台相机中的每一台。然后我在各种条件下拍摄了照片和视频。我不是专业摄影师,我没有对图像进行Imatest或任何其他特定测试(你可以阅读C/net),但这是一个普通人的经历,他用这三台相机并排拍摄照片和视频,这是一个你不常看到的比较。” “归根结底,这三款相机非常相似,但也有一些细微的差别。但这些差别将它们区分开来,并可能使你决定你更喜

“我无法决定这三款相机(以及它们的变体,索尼HX30和松下ZX20),因为对每款相机的许多评论都让它们听起来非常相似。因此,我出去买了(从接受退货的商家那里买的)这三台相机中的每一台。然后我在各种条件下拍摄了照片和视频。我不是专业摄影师,我没有对图像进行Imatest或任何其他特定测试(你可以阅读C/net),但这是一个普通人的经历,他用这三台相机并排拍摄照片和视频,这是一个你不常看到的比较。”

“归根结底,这三款相机非常相似,但也有一些细微的差别。但这些差别将它们区分开来,并可能使你决定你更喜欢其中一款而不是另一款。”

“一般来说,这些相机都不是数码单反的替代品。无论谁写的照片和数码单反一样好,都不能准确地说出来。此外,这些相机都不是高端摄像机的替代品。”

我需要的输出是

  • “我无法在这三款相机(以及它们的变体,索尼HX30和松下ZX20)之间做出决定,因为对每款相机的许多评论都让它们听起来非常相似。”
  • “所以,我出去(从接受退货的商人那里)买了这三台相机中的每一台。”
  • “然后我在各种条件下拍摄了照片和视频。”……等等

  • 现在,这段代码正在分隔句子。

    我不明白,您询问句子,然后发布按单词分隔的代码?我是不是误会了什么,我相信你在寻找这样的东西:

    text=“”[复制粘贴示例文本]“”“

    最终结果如下所示

    >>> sentences[0]
    [prints out first paragraph from "I couldn't decide..." to "which is a comparison you don't often see]
    >>> sentences[1]
    [prints out the 2nd paragraph "The bottom line is..."]
    
    你得到了句子的分隔,即第一段的第一句:

    >>> sentences[0][0]
    '"I couldn\'t decide between these three cameras (and their variants, the Sony HX30 and the Panasonic ZX20) because many of the reviews of each made the cameras sound very similar'
    
    第二句第一段

    >>> sentences[0][1]
    'So, I went out and bought (from merchants who accepted returns) one of each of these three cameras'
    
    第一句第二段

    >>> sentences[1][0]
    '"The bottom line is that these three cameras are very similar with a few minor differences.But those differences set them apart and may make you decide that you like one more than the other."'
    
    等等


    “然后我拿了……”不是第二段,因为它和前一句之间没有任何关系,这可能是因为你的格式不好(不是因为渲染),或者我对你需要什么/段落是什么的误解。

    拆分(“.”)有什么问题?谢谢,我已经找到了代码。您能帮我找出上面“”中段落的POS标签数量吗
    >>> sentences[0][1]
    'So, I went out and bought (from merchants who accepted returns) one of each of these three cameras'
    
    >>> sentences[1][0]
    '"The bottom line is that these three cameras are very similar with a few minor differences.But those differences set them apart and may make you decide that you like one more than the other."'