Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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根据长度和字符查找子字符串_Python_String_Invert - Fatal编程技术网

Python根据长度和字符查找子字符串

Python根据长度和字符查找子字符串,python,string,invert,Python,String,Invert,我正试图得到一个基于长度和/或字符关联的子字符串 绳子看起来像这样。 string=“1.11您可以拆分字符串,然后按所需顺序重新组合 string = " 1.11 << Z99E004Z " [string1, string2] = string.split("<<") result_string = string2 + "<<" + string1 string=“1.11istr=“1.11

我正试图得到一个基于长度和/或字符关联的子字符串

绳子看起来像这样。
string=“1.11您可以拆分字符串,然后按所需顺序重新组合

string = " 1.11 << Z99E004Z "
[string1, string2] = string.split("<<")
result_string = string2 + "<<" + string1

string=“1.11
istr=“1.11如果我没有错,你只想?我假设你的意思是“字母数字子串在左边,整数在右边。”。“虽然
1.11
实际上不是整数。如果子字符串的形式和长度不总是相同,请检查并使用它们匹配字母数字子字符串和数字。我想你可以从那里看到你需要做什么。这真的不清楚。显示预期结果。谢谢,这应该行得通,我没有提到的一件事是“实际上可以在空格上拆分,似乎行得通,谢谢。实际上,你可以使用空格作为分隔符,然后你需要调整到最后的字符串组合,因为生成的列表将有五个条目。
istr = " 1.11 << Z99E004Z "
pos = istr.find(" ",2)
str1 = istr[pos:] + istr[0:pos]
print("Input: ", istr)
print("Output: ", str1)istr = " 1.11 << Z99E004Z "
Input:   1.11 << Z99E004Z 
Output:   << Z99E004Z  1.11