-3

我有一个文本文件包含这种格式的“A 0001 1212 00 @@ word”,我想在访问 word 时打印然后只有 0001 1212 部分必须显示,00 也必须动态显示

4

1 回答 1

0

你试过什么?我并没有真正遵循您的格式。

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')

这是你想要的吗?这个文件只有一行吗?

于 2012-06-28T18:15:58.103 回答