sent="Software Development = 1831".
我想提取从字符串即“软件开发”只有文字的字符串。我如何在Python中解压缩。
sent="Software Development = 1831".
我想提取从字符串即“软件开发”只有文字的字符串。我如何在Python中解压缩。
您可以尝试split
:
>>> sent="Software Development = 1831"
>>> sent.split("=")[0]
'Software Development '
谢谢你现在工作:) –
>>> str="Software Development = 1831"
>>> str.split()
['Software', 'Development', '=', '1831']
or
>>> str.split("=")
['Software Development ', ' 1831']
最初你之间的空间 '=',因此你的代码看起来应该是这样
发送= “软件开发= 1831”
answer = sent.split(“=”)[0] #space before and after =
你已经试过了什么? – LoicM
'sent.split('=')[0] .strip()'+ SEARCH! – Arman