当前位置: 首页>>代码示例>>Python>>正文


Python Table.insert方法代码示例

本文整理汇总了Python中outputty.Table.insert方法的典型用法代码示例。如果您正苦于以下问题:Python Table.insert方法的具体用法?Python Table.insert怎么用?Python Table.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在outputty.Table的用法示例。


在下文中一共展示了Table.insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_table_insert

# 需要导入模块: from outputty import Table [as 别名]
# 或者: from outputty.Table import insert [as 别名]
 def test_table_insert(self):
     table = Table(headers=["python", "rules"])
     table.extend([[1, 2], [3, 4], [5, 6], [7, 8], [1, 2]])
     table.insert(0, [4, 2])
     table.insert(1, {"python": 9, "rules": 9})
     self.assertEquals(table[0], [4, 2])
     self.assertEquals(table[1], [9, 9])
     self.assertEquals(len(table), 7)
开发者ID:andreas-andrade,项目名称:outputty,代码行数:10,代码来源:test_Table_base.py

示例2: Table

# 需要导入模块: from outputty import Table [as 别名]
# 或者: from outputty.Table import insert [as 别名]
table = Table(headers=["City", "State", "Country"])
table.append(["Três Rios", "Rio de Janeiro", "Brazil"])
table.append(["Niterói", "Rio de Janeiro", "Brazil"])
table.append(["Rio de Janeiro", "Rio de Janeiro", "Brazil"])
table.append(["Porto Alegre", "Rio Grande do Sul", "Brazil"])
table.append(["São Paulo", "São Paulo", "Brazil"])

print "First 3 rows:"
for row in table[:3]:  # Slicing
    print row

# Change the two last rows:
table[-2:] = [["Junín", "Buenos Aires", "Argentina"], ["Ciudad del Este", "Alto Paraná", "Paraguay"]]
# Insert a row in the first position, using dict notation:
table.insert(0, {"City": "La Paz", "State": "La Paz", "Country": "Bolivia"})
print "New table:"
print table
print

table.reverse()
print "And the table in the reversed order:"
print table
print

popped_row = table.pop()
rio = ["Rio de Janeiro", "Rio de Janeiro", "Brazil"]
table.append(rio)  # repeated row
number_of_rios = table.count(rio)
index_of_first_rio = table.index(rio)
table.remove(rio)  # remove the first occurrence of this row
开发者ID:andreas-andrade,项目名称:outputty,代码行数:32,代码来源:08_table_methods.py

示例3: Table

# 需要导入模块: from outputty import Table [as 别名]
# 或者: from outputty.Table import insert [as 别名]
table = Table(headers=['City', 'State', 'Country'])
table.append(['Três Rios', 'Rio de Janeiro', 'Brazil'])
table.append(['Niterói', 'Rio de Janeiro', 'Brazil'])
table.append(['Rio de Janeiro', 'Rio de Janeiro', 'Brazil'])
table.append(['Porto Alegre', 'Rio Grande do Sul', 'Brazil'])
table.append(['São Paulo', 'São Paulo', 'Brazil'])

print 'First 3 rows:'
for row in table[:3]:
    print row

#Change the two last rows:
table[-2:] = [['Junín', 'Buenos Aires', 'Argentina'],
              ['Ciudad del Este', 'Alto Paraná', 'Paraguay']]
#Insert a row in the first position, using dict notation:
table.insert(0, {'City': 'La Paz', 'State': 'La Paz', 'Country': 'Bolivia'})
print 'New table:'
print table
print

table.reverse()
print 'And the table in the reversed order:'
print table
print

popped_row = table.pop()
rio = ['Rio de Janeiro', 'Rio de Janeiro', 'Brazil']
table.append(rio) #repeated row
number_of_rios = table.count(rio)
index_of_first_rio = table.index(rio)
table.remove(rio) #remove the first occurrence of this row
开发者ID:rennerocha,项目名称:outputty,代码行数:33,代码来源:8_table_methods.py


注:本文中的outputty.Table.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。