在列表中查找哪个元素错误(python)

时间:2019-03-25 14:10:36

标签: python-3.x

我有两个列表,englishclublistofallclub

我已经检查了englishclub中不是所有元素都在listofallclub中,但是我想找出listofallclub中缺少的元素

我希望列表很大。

listallclub = df.Club.tolist()

result =  all(elem in englishclub  for elem in  listallclub)

if result:
    print("Yes, englishclub  contains all elements in listallclub")    
else :
    print("No, englishclub  does not contains all elements in listallclub")

我希望我的输出成为englishclub中而不是listofallclub中的元素列表

2 个答案:

答案 0 :(得分:0)

ERROR DETAILS Following errors were detected during this operation. * [3/25/2019 8:48:24 AM] System.ArgumentException - Value does not fall within the expected range. - Source: System.Deployment - Stack trace: at System.Deployment.Application.NativeMethods.CorLaunchApplication(UInt32 hostType, String applicationFullName, Int32 manifestPathsCount, String[] manifestPaths, Int32 activationDataCount, String[] activationData, PROCESS_INFORMATION processInformation) at System.Deployment.Application.ComponentStore.ActivateApplication(DefinitionAppId appId, String activationParameter, Boolean useActivationParameter) at System.Deployment.Application.SubscriptionStore.ActivateApplication(DefinitionAppId appId, String activationParameter, Boolean useActivationParameter) at System.Deployment.Application.ApplicationActivator.Activate(DefinitionAppId appId, AssemblyManifest appManifest, String activationParameter, Boolean useActivationParameter) at System.Deployment.Application.ApplicationActivator.ProcessOrFollowShortcut(String shortcutFile, String& errorPageUrl, TempFile& deployFile) at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl, Uri& deploymentUri) at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivationWithRetry(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivationWithRetry(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl) at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)

答案 1 :(得分:0)

您可以使用列表理解,

e = [ec for ec in englishclub if ec not in listallclub]

if e:
    print("No, englishclub  does not contains all elements in listallclub")
    print("And they are")
    print(e)
else :
    print("Yes, englishclub  contains all elements in listallclub")