找回密码
 加入
搜索
查看: 1327|回复: 2

如何提取文本中奇数行,且前10位字符

[复制链接]
发表于 2009-1-8 18:11:29 | 显示全部楼层 |阅读模式
如题,如何提取文本中奇数行字符,且前10位字符
问题一解决。
且前10位字符如何办呢

[ 本帖最后由 fanchenglu 于 2009-1-9 15:09 编辑 ]
发表于 2009-1-8 18:48:52 | 显示全部楼层
au3里的读写位置,没有更改函数?
[au3]$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
$i=True
While 1
        If $i Then
    $line = FileReadLine($file)
        If @error = -1 Then
                     ExitLoop
            EndIf
            MsgBox(0, "Line read:", $line)
               
    Else
                $line = FileReadLine($file) ;au3里怎么没找到移动读写位置的函数?,这里读一行可以把读写位置移动下来
                If @error = -1 Then
                     ExitLoop
            EndIf
    EndIf
$i=Not($i)
Wend

FileClose($file)
[/au3]

[ 本帖最后由 akmm88 于 2009-1-8 18:50 编辑 ]
 楼主| 发表于 2009-1-9 01:03:33 | 显示全部楼层
$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
$i=1
While 1
    If $i Then
    $line = FileReadLine($file,$i)
        If @error = -1 Then 
             ExitLoop
        EndIf
        MsgBox(0, "Line read:", $line)
        
    Else
        $line = FileReadLine($file,$i) ;au3里怎么没找到移动读写位置的函数?,这里读一行可以把读写位置移动下来
        If @error = -1 Then 
             ExitLoop
        EndIf
    EndIf
$i=$i+2;如此修改,已经解决
Wend

FileClose($file)


[ 本帖最后由 fanchenglu 于 2009-1-9 01:06 编辑 ]
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-10 00:23 , Processed in 0.084517 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表