异常说明
1 2 3 4 5 6 |
test_count = 10000 #sys.maxsize # 指定测试次数 if __name__=='__main__': global test_count test(test_count) while True: time.sleep(100) |
这样写会报错
1 2 |
E:/autoHtp.py:65: SyntaxWarning: name 'test_count' is assigned to before global declaration global test_count |
语法错误:全局语句不能再使用之前初始化
正确的写法
1 2 3 4 5 6 7 8 |
global test_count if __name__=='__main__': global test_count test_count = 10000 test(test_count) while True: time.sleep(100) |
未经允许不得转载:Python在线学习 » Python异常-SyntaxWarning: name ‘xxx’ is assigned to before global declaration