-3
我有一个文本文件,包含此格式的“A 0001 1212 00 @@ word”,我想打印时访问单词然后只有0001 1212部分必须与00一起显示也有动态显示使用python获取文本文件中的特定单词
我有一个文本文件,包含此格式的“A 0001 1212 00 @@ word”,我想打印时访问单词然后只有0001 1212部分必须与00一起显示也有动态显示使用python获取文本文件中的特定单词
你试过了什么?我没有真正遵循你的格式。
f=open(filepath, 'r')
hold = f.read()
#hold now = 'A 0001 1212 00 @@ word'
holdout = hold.replace('@@ word','')
#holdout now = 'A 0001 1212 00 '
#the replace call uses this format
#string.replace('what it is looking for', 'what it is going to be')
这是你想要的吗?这个文件只有一行吗?
只有文本文件包含“A 0001 1212 00 @@ word”ok当我试图获取“word”时,那么0001 1212文本应该显示在输出文件 – testing
中您可以将数据作为字符串导入,然后执行字符串 - 'word' 。这是你在你的输出中寻找什么?你可以做一个格式化和所需的后格式化例子之前? (你应该编辑你的问题)。 – deadstump
@testing查看我的编辑。这是你想要的吗? – deadstump