假设文本文件的形式为-email:passwordemail:passwordemail:password等等,这里是你如何提取每一块afile = open("yourfile.txt", "r')for line in afile: pieces = line.split(":") email = pieces[0] password = pieces[1] #do whatever else you need to with each email and password here>您必须确保您的 Python 文件与 .txt 文件位于同一目录中,才能按原样正确运行(当然,将“yourfile.txt”替换为您的实际文件名)。唯一需要注意的是电子邮件地址中是否包含“:”。如果是,例如“abc:def@email.com”,则“abc”将被设置为电子邮件,而“def@email.com”将被设置为密码。如果电子邮件可以包含冒号,那么您需要做更多的工作来更好地拆分每一行。但是如果它们不包括冒号,你就设置好了。