paip.元数据驱动的转换-读取文件行到个list理念 uapi java php python总结

paip.元数据驱动的转换-读取文件行到个list理念 uapi java php python总结

#两个思路
1.思路例如以下:使用file_get_contents()获取txt文件的内容,然后通过explode()把获得的字符串转化为数组。获得数组长度能够使用count()函数
2.使用依照行读取api

在正則表達式中,有一个 是newline的意思,又有一个 是carriage return(就是这个导致了白痴中文翻译"回车")的意思。在处理String或者console输出的时候,不管带上哪个都能换行。

作者 老哇的爪子 Attilax 艾龙,  EMAIL:1466519819@qq.com
转载请注明来源: http://blog.csdn.net/attilax

#---uapi  file2list()

#-----python  的问题是还要替换换行符 跟回车键..
#todox read file lines to list (not arr ,arr is tech word ,but list is life word)
def file2list(file) :   
    rplc_list = []      ;

    for line in open(f, encoding="utf-8"):
            if( len(trim(line))==0):
                break
                #endif
            #print(line)
            line=trim(line)
            line=line.replace(" ", "");   line=line.replace(" ", "")
            rplc_list.append(line)
    #end for
    return  rplc_list
    
#------java
#-------php

$file = '2010-12-15.txt';
$content = file_get_contents($file);
//echo $content;

$array = explode(" ", $content);
//print_r($array);

for($i=0; $i〈count($array); $i++)
{
echo $array[$i].'〈br /〉';
}
    
   
原文地址:https://www.cnblogs.com/hrhguanli/p/3878021.html