1.用del删除对对象的引用 >>> a = 123 >>> a 123 >>> del a >>> a Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError : name 'a' is not defined 2.整型 (1)布尔型 该类型取值范围只要两个值:布尔值True 和…
4.3 终止进程的运行 若要终止进程的运行,可以使用下面四种方法: • 主线程的进入点函数返回(最好使用这个方法) . • 进程中的一个线程调用E x i t P r o c e s s函数(应该避免使用这种方法) . • 另一个进程中的线程调用Te r m i n a t e P r o c e s s函数(应该避免使用这种方法) . • 进程中的所有线程自行终止运行(这种情况几乎从未发生) . 这一节将介绍所有这四种方法,并且说明进程结束时将会发生什么情况. 4.3.1 主线程的进入点函数返…
6-10.字符串.写一个函数,返回一个跟输入字符串相似的字符串,要求字符串的大小写反转,比如,输入“Mr.Ed”,应该返回“mR.eD”作为输出.[答案]代码如下: #!/usr/bin/env python from lib2to3.fixer_util import String #string lower into upper,upper into lower input = raw_input('Please input a string: ') output = '' for i in…
6-8.列表.给出一个整型值,返回代表该值得英文,比如输入89会返回“eight-nine”.附加题:能够返回符合英文语法规律的新式,比如输入89会返回“eighty-nine”.本练习中的值假定在0~1000.[答案]代码如下: number = int(raw_input('Please input a number between 1 to 1000: ... ')) units = ['zero', 'one', 'two', 'three', 'four', 'five', 'six'…
1.标准类型运算符. 写一段脚本,输入一个测验成绩,根据下面的标准,输出他的评分成绩(A-F). #coding:utf8 a = raw_input() a = int(a) if (a > 100) or (a < 0): print "输入错误,请输入0-100的数字" elif(a >=90): print "A" elif(a>=80): print "B" elif(a >= 70): print &qu…
4-1Python objects All Python objects have three attributes:type,ID,and value. All are readonly with a possible expection of the value(which can be changed only if the object is mutable). 4-5str()and repr() repr() is a built-in function while str() wa…
9–1. 文件过滤. 显示一个文件的所有行, 忽略以井号( # )开头的行. 这个字符被用做Python , Perl, Tcl, 等大多脚本文件的注释符号.附加题: 处理不是第一个字符开头的注释. filename = input("输入文件名:") with open(filename) as f: for i in f: if i.startswith('#'): continue else: print(i, end='') 9–2. 文件访问. 提示输入数字 N 和文件 F,…
4.2 CreateProcess函数 可以用C r e a t e P r o c e s s函数创建一个进程: BOOL CreateProcessW( _In_opt_ LPCWSTR lpApplicationName, _Inout_opt_ LPWSTR lpCommandLine, _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes…