Created
January 19, 2014 16:57
-
-
Save zs1621/8507524 to your computer and use it in GitHub Desktop.
python 全局變量錯誤
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
# | |
# Author : Rhapsodyzs | |
# E-mail : zs1213yh@gmail.com | |
# Date : 14/01/20 00:42:52 | |
# Desc : 全局變量錯誤 | |
# | |
c = [(1,2), (2, 3), (3, 4)] | |
a = [] | |
b = {} # 將此放在循環外 | |
for i in c: | |
b = {} #將此語句放入循環內部 | |
b['user'] = i[0] | |
b['dd'] = i[1] | |
a.append(b) | |
print a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment