且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python:将文件中的单词加载到一个集合中

更新时间:2023-12-02 20:34:22

字符串的 strip() 方法去除两端的空格.

The strip() method of strings removes whitespace from both ends.

set(line.strip() for line in open('filename.txt'))