从python中的列表中搜索

时间:2015-12-09 22:07:15

标签: python

我正在尝试从python中的列表中搜索。每当我输入搜索词时,它总是说“没有推文包含搜索”,即使我知道该词语在列表中。我做错了什么?

elif(ch==3):
        match = 0
        tweetlist.reverse()
        if tweetlist == []:
            print("There are no tweets to search.\n")
            continue
        else:
            search = input("What would you like to search for? ")
            for tweets in tweetlist:
                if(search in tweetlist):
                    match = 1
                if match == 1:
                    print ("Search Results")
                    print("----------")
                    print(tweets.get_author(), "-", tweets.get_age())
                    print(tweets.get_text(), "\n")
                elif match == 0:
                    print("No tweets contained,", search, "\n")

1 个答案:

答案 0 :(得分:1)

试试这个:

import UIKit
import Parse

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        if (PFUser.currentUser() != nil) {
            let vc = self.storyboard!.instantiateViewControllerWithIdentifier("summaryView")
            self.presentViewController(vc, animated: true, completion: nil)
        }
    }
}