为什么python list.remove返回不同​​的结果

时间:2018-07-11 02:34:18

标签: python list for-loop

为什么public static string RequestWithProxies(string url, string[] proxies) { var client = new WebClient { Credentials = new NetworkCredential(username, password) }; var result = String.Empty; foreach (var proxy in proxies) { client.Proxy = new WebProxy(proxy); try { result = client.DownloadString(new Uri(url)); } catch (Exception) { if (!String.IsNullOrEmpty(result)) break; } } if (String.IsNullOrEmpty(result)) throw new Exception($"Exhausted proxies: {String.Join(", ", proxies)}"); return result; } 语句返回不同的结果?:

输入1:

break

输出1:

list1 = [1,2,3,4]
for i in range(len(list1)):
    for i in list1:
        list1.remove(i)
        print(i, list1)
        #break

输入2:

(1, [2, 3, 4])
(3, [2, 4])
(2, [4])
(4, [])

输出2:

for i in range(len(list1)):
    for i in list1:
       list1.remove(i)
       print(i, list1)
       break

0 个答案:

没有答案