用另一个数字(ID)替换文件中的数字(ID) [英] Replacing a number(ID) in the file with another number(ID)

查看:56
本文介绍了用另一个数字(ID)替换文件中的数字(ID)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个如下所示的文件数据,我的要求是用其他ID号替换号码的ID。有没有像'fseek这样的方法()"因此我们可以用所需的ID替换ID,而无需更换文件的归档格式,同时更换


提前谢谢

PSB


输入:

Hi ,

I have a file data as shown below and my requirement is to replace the ID of the number with some other ID number.Is there any method like "fseek()" so that we can replace the ID with the required ID without chnaging the filed format of the file while replacing

Thanks in advance
PSB

Input :

展开 | 选择 | Wrap | 行号

推荐答案





我有一个如下所示的文件数据,我的要求是用一些其他ID号替换该号码的ID。是否有任何像fseek()这样的方法....
Hi ,

I have a file data as shown below and my requirement is to replace the ID of the number with some other ID number.Is there any method like "fseek()" ....



>>>帮助(文件)

模块中的类文件帮助__builtin __:


类文件(对象)

| file(name [,mode [,buffering]]) - >文件对象

|

|寻求(...)

| seek(offset [,whence]) - >没有。移动到新文件位置。

|

|参数偏移量是字节数。可选参数whence默认为

| 0(从文件开始偏移,偏移量应>> = 0);其他值是1

| (相对于当前位置移动,正面或负面)和2(相对于文件结尾移动

|,通常为负数,尽管许多平台允许

|寻求超越一个文件的结尾)。如果文件以文本模式打开,

|只有tell()返回的偏移是合法的。使用其他补偿导致

|未定义的行为。

|请注意,并非所有文件对象都是可搜索的。

|

|告诉(...)

| tell() - >当前文件位置,一个整数(可能是一个长整数)。

>>> help(file)
Help on class file in module __builtin__:

class file(object)
| file(name[, mode[, buffering]]) -> file object
|
| seek(...)
| seek(offset[, whence]) -> None. Move to new file position.
|
| Argument offset is a byte count. Optional argument whence defaults to
| 0 (offset from start of file, offset should be >= 0); other values are 1
| (move relative to current position, positive or negative), and 2 (move
| relative to end of file, usually negative, although many platforms allow
| seeking beyond the end of a file). If the file is opened in text mode,
| only offsets returned by tell() are legal. Use of other offsets causes
| undefined behavior.
| Note that not all file objects are seekable.
|
| tell(...)
| tell() -> current file position, an integer (may be a long integer).


我有一个示例文件,如下所示。我想替换PointID,如下面的代码片段所示

I have a sample file ,as shown below.I would like to replace the PointID as shown below in the piece of code

展开 | 选择 < span class =codeDivider> | Wrap | 行号



我有一个示例文件,如如下所示。我想替换下面的代码中的PointID

I have a sample file ,as shown below.I would like to replace the PointID as shown below in the piece of code

展开 | 选择 | Wrap | 行号


这篇关于用另一个数字(ID)替换文件中的数字(ID)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆