4Manuals

  • PDF Cloud HOME

如何根据句点或换行符出现的位置将文本分成几段? Download

    如何将文本边界框与pyplot.Rectangle对齐? 导入类问题 在Python数据框中选择列时出错 使用Rabbit的pika确认消息 如何在按住键的同时暂停VideoStream? Python OpenCV TypeError:无法处理此数据类型 使用buildozer不会下载sdl2_image SMTPSenderRefused,421,超出超时 Tensorflow多线程推理比单线程推理慢 关于python中变量的困惑。 python如何使用变量?

我的文字是:

'3. COMMENCEMENT; TERM OF LEASE; AND OPTION TO RENEW\nThe initial term of this Lease shall be for a period of Five (5) years commencing on'

我想要以下列表:

[
    '3. COMMENCEMENT; TERM OF LEASE; AND OPTION TO RENEW',
    'The initial term of this Lease shall be for a period of Five (5) years commencing on'
]

1 个答案:

答案 0 :(得分:0)

>>> initial_statement = "3. COMMENCEMENT; TERM OF LEASE; AND OPTION TO RENEW\nThe initial term of this Lease shall be for a period of Five (5) years commencing on"
>>> temp_list = initial_statement.split("\n")
>>> print(temp_list)
['3. COMMENCEMENT; TERM OF LEASE; AND OPTION TO RENEW', 'The initial term of this Lease shall be for a period of Five (5) years commencing on.']

或再次将其设为字符串

>>> final_result = ""
>>> for i in temp_list:
...     final_result += i
... 
>>> print(final_result)
3. COMMENCEMENT; TERM OF LEASE; AND OPTION TO RENEWThe initial term of this Lease shall be for a period of Five (5) years commencing on.



Similar searches
    <a href>链接在iPhone上不可见 Numpy从Google云端存储加载内存映射数组(mmap_mode) 无法推送git子树更改 Samsung SR-29NXB Refrigerator User Manual 需要有关oxmlelement的指导和技巧