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

(已解决):两个数组之间的比对问题!

[复制链接]
发表于 2010-9-11 17:23:52 | 显示全部楼层 |阅读模式
本帖最后由 3131806 于 2010-9-13 10:56 编辑

现有两个txt文档,分别为1.txt,2.txt
1.txt内容如下:
中国
美国
英国
2.txt内容如下
中国
美国
法国
德国
我现在把这两个文档都读入到数组里,进行比对,然后要把两个文档中相同的国家名保存到3.txt里
#include <Array.au3>

Dim $a,$b

_FileReadToArray ("c:\1.txt",$a)

_FileReadToArray ("c:\2.txt",$b)

下面怎么做啊,大侠们,帮帮忙!
发表于 2010-9-13 00:48:08 | 显示全部楼层
回复 1# 3131806

我在这里看到一个UDF,去掉"Not"就可以实现
http://www.autoitx.com/forum.php ... hlight=%B6%D4%B1%C8
#include <file.au3>

_FileListCompare("1.txt","2.txt","3.txt")

Func _FileListCompare($hSouce,$hTarget,$hOutPut)

        $hLine_S = _FileCountLines($hSouce)

        $hCon_T = FileRead($hTarget)

        For $hSi = 1 To $hLine_S

                $hS_String = FileReadLine($hSouce,$hSi)

                If StringInStr($hCon_T,$hS_String) Then

                        FileWriteLine($hOutPut,$hS_String)

                EndIf

        Next

EndFunc
 楼主| 发表于 2010-9-13 10:54:12 | 显示全部楼层
谢谢大哥,真的好用,嘿嘿!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-3 08:20 , Processed in 0.078640 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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