datafile.txt #文件 Man: this is the right room for an argument. Other Man: I've told you once. Man: No you haven't Other Man: Yes, I have. (pause) Man: When? Other Man: Just now. Man: No you didn't Other Man: Yes I did. Man: You didn't Other Man: I'm…
linux读取文件是经常要用到的操作,以下示例(说明看注释): #读取文件snlist.txt中的每一行内容赋给sn变量 while read sn do echo ">>>>>>>sn is $sn" # 判断是否是文件 if [ ! -d "$sn" ];then echo $sn "not existed" else # 对sn进行"/"拆分并获取最后一个结果,如lib/aa结果…
python2的编码实在是个头疼的问题,编码问题也将作为一个长期的话题,遇到问题随时补充. 这次的问题比较简单,是在做词云wordcloud的时候发现的,作用就是从文本文件中读取文字,将其制作成词云.部分代码如下: import chardet from wordcloud import WordCloud import matplotlib.pyplot as plt with open("C:\\Users\\fyc\\Desktop\\json.txt", "r&quo…