-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththird.py
More file actions
43 lines (38 loc) · 930 Bytes
/
third.py
File metadata and controls
43 lines (38 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
author:spring
author_email:dengchagnqing@gmail.com
sit:www.ssjike.com
"""
#list opration
movies = ["taitannikehao",1969,"sejie",2010,
["The mean of life",2012,"spring","yini"]]
#genju tiaojian lai xunfan bianli list
def print_lol(the_list,indent=False,level=0):
for the_item in the_list:
if isinstance(the_item,list):
print_lol(the_item,indent,level+1)
else:
if indent:
for tab_stop in range(level):
print("\t",end='')
print(the_item)
print_lol(movies,True,2)
#==========================
import os
print(os.getcwd())#返回当前目录
#切换到指定目录
#os.chdir('../home/software')
#对异常进行处理
try:
data = open('text.txt')
for each_line in data:
try:
(role,line_spoken) = each_line.split(':',1)
print(role,end='')
print('said:',end='')
print(line_spoken,end='')
except ValueError:
pass
data.close()
except IOError:
print(data.readline(),end='')