python习题 (1):login】的更多相关文章

#!/uer/bin/env python # _*_ coding: utf-8 _*_ import sys retry_limit = 3 retry_count = 0 account_file = 'accounts.txt' lock_file = 'account_lock.txt' while retry_count < retry_limit: #循环体限制3次内执行 username = raw_input('\033[32; Username : \033[0m') #输入…
#improt time module for count down puase time import time #set var for loop counting counter=1 #login setting while counter<=3: print('please enter username: ') username=input() print('please enter password: ') password=input() #dict for username and…
[习题] 指定一个源文件,实现copy到目标目录.例如把/tmp/sample1.txt 拷贝到/tmp/sample2.txt原文件需要有读权限(默认rt权限),目标文件需要给写(w即可)权限. In [8]: with open('/tmp/sample1.txt',encoding='UTF-8') as f1: ...: with open('/tmp/sample2.txt','w',encoding='utf-8') as f2: ...: content = f1.read() .…
1.26个字母大小写成对打印,例如:Aa,Bb...... 方法1: for i in range(26): print(chr(65+i)+chr(97+i)) 方法2: for i in range(26): print(chr(ord("A")+i),chr(ord("a")+i)) 2.一个list包含10个数字,然后生成一个新的list,要求新的list里面的数都比之前的数多1 s = list(range(10))list = []for i in s:…
用以记录python学习过程中做过的小习题~ ヾ(◍°∇°◍)ノ゙ 1.生成两个列表,分别存放将100以内的偶数&奇数 odd_number=[] even_number=[] for i in range(1,101): if i%2==0: odd_number.append(i) else: even_number.append(i) print 'the odd number list is:','\n',odd_number print 'the even number list is…
目录 1.习题 11: 提问 2.习题 12: 提示别人 3.总结 1.习题 11: 提问 学习目标:了解人机交互场景,熟悉raw_input 的用法. 1.在 Python2.x 中 raw_input( ) 和 input( ),两个函数都存在,具体区别详情请参考习题5,其中区别为: raw_input( ) 将所有输入作为字符串看待,返回字符串类型. input( ) 只能接收"数字"的输入,在对待纯数字输入时具有自己的特性,它返回所输入的数字的类型( int, float ).…
目录 1.习题 8: 打印,打印 2.习题 9: 打印,打印,打印 3.习题 10: 那是什么? 3.1.转义序列: 4.习题总结: 1.习题 8: 打印,打印 学习目标:继续学习 %r 的格式化输出. 习题八中的练习代码是: #! -*-coding=utf-8 -*- formatter = "%r %r %r %r %r " print formatter % (1, "hello", [1,2,3], (1,2,3), {"name":&…
目录 1.习题 6: 字符串(string) 和文本 2.加分习题: 3.我的答案 4.习题总结 5.习题 7: 更多打印 6.习题总结 1.习题 6: 字符串(string) 和文本 学习目标:了解字符串的定义,学会使用复杂的字符串来建立一系列的变量.学会命名有意义的变量名 习题六中的练习代码是: #! -*-coding=utf-8 -*- x = "There are %d types of people." % 10 binary = "binary" do…
1.习题 5: 更多的变量和打印 学习目标:了解用户输入方法,明白pthon2和Python3之间的用户输入的区别.了解格式化字符串(format string)的概念,学会如何创建包含变量内容的字符串.使用专门的格式和语法把变量的内容放到字符串里,然后进行格式化的打印输出. 1.1.用户输入 在Python3中通常使用的input() 函数直接和用户进行交互,用于等待用户的输入. 在Python2中通常使用raw_input() 函数来和用户进行交互,基本上raw_input() = inpu…
1.习题 4: 变量(variable)和命名 学习目标:了解Python中变量的定义,学习定义简明易记的变量名 变量:变量是存储内存中的值,就是每定义一个变量就会在内存中开辟一个空间.基于变量的类型.解释器会分配指定的内存,并解决什么数据可以被存储到内存中. 在Python中使用变量时,变量不需要提前定义,只需要给变量赋值即可,赋值的过程就是创建这个变量的过程.但是如果要使用这个变量,必须要给这个变量赋值. 变量的命名规则: 变量名只能是字母.数字.下划线的任意组合,但是不能是数字开头,且不能…