本文整理汇总了Python中caca.canvas.Canvas.get_char方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.get_char方法的具体用法?Python Canvas.get_char怎么用?Python Canvas.get_char使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类caca.canvas.Canvas
的用法示例。
在下文中一共展示了Canvas.get_char方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_put_char
# 需要导入模块: from caca.canvas import Canvas [as 别名]
# 或者: from caca.canvas.Canvas import get_char [as 别名]
def test_put_char(self):
""" module canvas: Canvas.put_char()
"""
cv = Canvas(10, 1)
self.assertEqual(1, cv.put_char(0, 0, "z"))
self.assertEqual(1, cv.put_char(1, 0, "é"))
self.assertEqual("z", cv.get_char(0, 0))
self.assertEqual("é", cv.get_char(1, 0))
self.assertRaises(CanvasError, cv.put_char, "a", 1, 2)
self.assertRaises(CanvasError, cv.put_char, "a", 1, "b")
示例2: test_printf
# 需要导入模块: from caca.canvas import Canvas [as 别名]
# 或者: from caca.canvas.Canvas import get_char [as 别名]
def test_printf(self):
""" module canvas: Canvas.printf()
"""
word1, word2 = "test", "string"
cv = Canvas(10, 1)
self.assertEqual(10, cv.printf(0, 0, "%s%s", word1, word2))
liststring = []
for i in range(0, 10):
liststring.append(cv.get_char(i, 0))
self.assertEqual("teststring", "".join(liststring))
self.assertRaises(CanvasError, cv.printf, 0, 0, 111)
self.assertRaises(CanvasError, cv.printf, 0, "z", "abc %s", "def")
示例3: test_put_str
# 需要导入模块: from caca.canvas import Canvas [as 别名]
# 或者: from caca.canvas.Canvas import get_char [as 别名]
def test_put_str(self):
""" module canvas: Canvas.put_str()
"""
cv = Canvas(10, 1)
self.assertEqual(10, cv.put_str(0, 0, "teststring"))
liststring = []
for i in range(0, 10):
liststring.append(cv.get_char(i, 0))
self.assertEqual("teststring", "".join(liststring))
self.assertRaises(CanvasError, cv.put_str, 0, 0, 111)
self.assertRaises(CanvasError, cv.put_str, 0, "z", "abc")
示例4: test_get_char
# 需要导入模块: from caca.canvas import Canvas [as 别名]
# 或者: from caca.canvas.Canvas import get_char [as 别名]
def test_get_char(self):
""" module canvas: Canvas.get_char()
"""
cv = Canvas(1, 1)
self.assertEqual(" ", cv.get_char(0, 0))