本文整理汇总了Python中nester.print_lol函数的典型用法代码示例。如果您正苦于以下问题:Python print_lol函数的具体用法?Python print_lol怎么用?Python print_lol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_lol函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_lol
def print_lol(the_list,level):
for each_item in the_list:
if isinstance(each_item,list):
print_lol(each_item)
else:
for tab_stop in range(level):
print("\t",end="")
print(each_item)
示例2: print_lol
# def print_lol(the_list):
# for each_item in the_list:
# if isinstance(each_item, list):
# print_lol(each_item)
# else:
# print(each_item)
import nester
from nester import print_lol
m_array = ['a','b','c',['d',['e','f']]]
# namespace
# nester.print_lol(m_array)
#
# print_lol(m_array)
# nester.print_lol(m_array,3);
nester.print_lol(m_array);
示例3:
#!/usr/bin/python
import nester;
mylist = ["dave","dtormey","has","an","impressive","six-pack" ]
nester.print_lol(mylist)
示例4:
import nester
cast = ["Palin", "Cleese", "Idle", "Jones", "Gilliam", "Chapman"]
nester.print_lol(cast)
示例5:
import nester
cast = ["Palin", "Cleese",["dd", "dd",[1,1,1]], "Idle", "Jones", "Gillian", "Chapman"]
nester.print_lol(cast, 0)
示例6: print
#print_lol(man, fn = man_file)
#print_lol(other, fn = other_file)
except IOError as err1:
print('File error: ' + str(err1))
except pickle.PickleError as perr:
print('Pickle Error: ' + str(perr))
try:
with open('man_data_1.txt', 'rb') as man_file:
new_man = pickle.load(man_file)
except IOError as err1:
print('File error: ' + str(err1))
except pickle.PickleError as perr:
print('Pickle Error: ' + str(perr))
print_lol(new_man)
# Git practice
示例7: print
man=[]
other=[]
try:
data=open('sketch.txt')
for each_line in data:
try:
(role,line_spoken) = each_line.split(':',1)
line_spoken=line_spoken.strip()
if role=='Man':
man.append(line_spoken)
if role=='Other Man':
other.append(line_spoken)
except ValueError:
pass
data.close()
except IOError:
print('the data file is missing!')
try:
with open('man_data.txt','w')as man_file:
print_lol(man,fh=man_file)
with open('other_data.txt','w')as other_file:
print_lol(other,fh=other_file)
except IOError as err:
print('File error:'+str(err))
示例8: open
data = open('sketch.txt') #打开文件
for each_line in data:#遍历文件
try:
(role,line_spoken) = each_line.split(':',1) #将每行按照:分成2部分
line_spoken = line_spoken.strip()#去除多余空格
if role == 'Man':#如果role是man, 把line_spken 压入man list
man.append(line_spoken)
elif role == 'Other Man':
other.append(line_spoken)
except ValueError:
pass
data.close()#关闭I/O
except IOError:
print('The data file is missing!')
try:
with open('man_data3.txt','w') as out_man:
print_lol(man,fh=out_man)
with open('other_data3.txt','w') as out_other:
print_lol(other,fh=out_other)
except IOError as err:
print('File Error: '+str(err))
try:
with open('man_data3.txt','w') as out_man,open('other_data3.txt','w') as out_other:
print_lol(man, fh=out_man)
print_lol(other,fh=out_other)
except IOError as err:
print('File Error: '+str(err))
示例9: open
other = []
try:
os.chdir('/home/dlete/python_lab/ch04')
data = open('sketch.txt')
for each_line in data:
try:
(role, line_spoken) = each_line.split(":", 1)
line_spoken = line_spoken.strip()
if role == 'Man':
man.append(line_spoken)
elif role == 'Other Man':
other.append(line_spoken)
except ValueError:
pass
data.close()
except IOError:
print('The data file is missing')
try:
with open("data_man.txt", "w") as file_man:
nester.print_lol(man, fh=file_man)
with open("data_other.txt", "w") as file_other:
nester.print_lol(other, fh=file_other)
except IOError as err:
print('File error: ' + str(err))
示例10: print
other.append(line_spoken)
except ValueError:
pass
data.close()
except IOError:
print('The data file is missing')
try:
with open("data_man.txt", "wb") as file_man:
pickle.dump(man, file_man)
with open("data_other.txt", "wb") as file_other:
pickle.dump(other, file_other)
except IOError as err:
print('File error: ' + str(err))
try:
with open('data_man.txt', 'rb') as file_man:
new_man = pickle.load(file_man)
with open('data_other.txt', 'rb') as file_other:
new_other = pickle.load(file_other)
except IOError as err:
print('File error: ' + err)
except pickleError as perr:
print('Pickling error: ' + perr)
nester.print_lol(new_man)
nester.print_lol(new_other)
示例11:
import nester
movies = ['hello', 'world', 91, ['good', 23, ['morning', 23], 'yes', [23, 45, 0.2, 'large'], 32], ['yesterday']]
nester.print_lol(movies, 0)
nester.print_lol(movies, 1)
nester.print_lol(movies, 2)
示例12: open
import os
import nester
target = ["danile", "michael", ["aj","dk"]]
#print(target)
nester.print_lol(target, True, 3)
print(os.getcwd())
###
data = open("sketch.txt")
for each_line in data:
try:
(role, line_spoken) = each_line.split(":")
#print(each_line, end="")
print(role, end="")
print(" said: ", end="")
print(line_spoken, end="")
except:
pass
data.close()
示例13: main
#
# Created: 06-01-2013
# Copyright: (c) Administrator 2013
# Licence: <your licence>
#-------------------------------------------------------------------------------
def main():
pass
if __name__ == '__main__':
main()
import nester
print(dir(nester))
print(nester.__file__)
cast=['Palin','Cleese','idle','Jones','Gilliam','Chapman']
nester.print_lol(cast)
print("####################################################")
from nester import print_lol
##print(dir(nester))
##print(nester.__file__)
cast=['Palin','Cleese','idle','Jones','Gilliam','Chapman']
print_lol(cast)
print("####################################################")
from nester import *
##print(dir(nester))
##print(nester.__file__)
cast=['Palin','Cleese','idle','Jones','Gilliam','Chapman']
print_lol(cast)
print("####################################################")
示例14: open
import nester
cast = ['Palin','Cleese','Idle','Jone','Gilliam']
try:
with open ('test.txt','w') as out1:
nester.print_lol(cast,fh = out1)
except IOError as err:
print('Error: '+str(err))
示例15:
'''
Created on 2015. 11. 2.
@author: User
'''
import nester
exlist=['plain', 'clese', 'idel', 'gillen', 'eidlfgks', 'chapman']
nester.print_lol(exlist)