如何在python中只打印字符串中的某些单词?假设我想只打印第3个单词(这是一个数字)和第10个单词
而每次文本长度可能不同
mystring = "You have 15 new messages and the size is 32000"
谢谢.
我有以下代码:
code1 = ("\xd9\xf6\xd9\x74\x24\xf4\x5f\x29\xc9\xbd\x69\xd1\xbb\x18\xb1")
print code1
code2 = open("code.txt", 'rb').read()
print code2
Run Code Online (Sandbox Code Playgroud)
code1输出:
???t$?_)?½i?»±
Run Code Online (Sandbox Code Playgroud)
code2输出:
"\xd9\xf6\xd9\x74\x24\xf4\x5f\x29\xc9\xbd\x69\xd1\xbb\x18\xb1"
Run Code Online (Sandbox Code Playgroud)
我需要code2(我从文件中读取)与code1具有相同的输出.
我怎么解决这个问题?