# -*- coding: cp936 -*-
import random
if __name__ == '__main__':
checkcode = ""
for i in range(4):
index = random.randrange(0,4)
if index != i and index + 1 != i:
checkcode += chr(random.randint(97, 122))
elif index + 1 == i:
checkcode += chr(random.randint(65, 90)
else:
checkcode += str(random.randint(1,9))
print("验证码:" + checkcode)
在else: 这里报syntax错误,感觉没啥问题呀。求指教
# -*- coding: cp936 -*-
import random
if __name__ == '__main__':
checkcode = ""
for i in range(4):
index = random.randrange(0,4)
if index != i and index + 1 != i:
checkcode += chr(random.randint(97, 122))
elif index + 1 == i:
checkcode += chr(random.randint(65, 90)
else:
checkcode += str(random.randint(1,9))
print("验证码:" + checkcode)
在else: 这里报syntax错误,感觉没啥问题呀
python有c语言风格也有c++风格也有java风格,至于学嘛:最好学了c c++ java再来学python,秒会,而且完全不会有蒙蔽状态;当然!最快速的方法就是直接入手python,先找一本python基础的书学基础,实战的时候多看看api 函数不知道怎么用的时候 要懂得help命令查看用法,一定要多敲代码多想