我有一个脚本,其中将一个很长的类型参数str传递给一个函数:
parser = argparse.ArgumentParser(description='Auto-segments a text based on the TANGO algorithm (Rie Kubota Ando and Lillian Lee, "Mostly-Unsupervised Statistical Segmentation of Japanese Kanji Sequences" (Natural Language Engineering, 9(2):127-149, 2003)).')
Run Code Online (Sandbox Code Playgroud)
我想将此脚本中的行长度限制为 79 个字符,这意味着在相关字符串的中间换行。简单地以 79 换行会产生这样的结果,这在语法上是错误的:
parser = argparse.ArgumentParser(description="Auto-segments a text based on
the TANGO algorithm (Rie Kubota Ando and Lillian Lee, 'Mostly-Unsupervis
ed Statistical Segmentation of Japanese Kanji Sequences' (Natural Langua
ge Engineering, 9(2):127-149, 2003)).")
Run Code Online (Sandbox Code Playgroud)
PEP 8有在各种非参数字符串内部位置换行的指南,但是有没有办法在参数字符串的中间换行?
(相关但不太重要的问题:在(python)脚本中打破自然语言文本中间词的明智/传统方法是什么?)