• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python zhpy.convertor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zhpy.convertor函数的典型用法代码示例。如果您正苦于以下问题:Python convertor函数的具体用法?Python convertor怎么用?Python convertor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_try

def test_try():
    """
    test try except
    """
    assert convertor("尝试: 导入 a; 异常 ImportError, e: 打印 e") == \
                "try: import a; except ImportError, e: print e"
    assert convertor("引发 例外") == "raise Exception"
开发者ID:Abelisme,项目名称:zhpy,代码行数:7,代码来源:test_controlflow_cn.py


示例2: test_string

def test_string():
    """
    same as print test
    """
    s = "hello.py"
    assert convertor("s.開始字串('he')") == "s.startswith('he')"
    assert convertor("s.結束字串('he')") == "s.endswith('he')"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:7,代码来源:test_types_tw.py


示例3: test_import

def test_import():
    """
    test import statement with from/import/as
    """
    assert convertor("载入 sys") == "import sys"
    assert convertor("载入 sys 取名 unix") == "import sys as unix"
    assert convertor("从 os 载入 path 取名 url") == "from os import path as url"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:7,代码来源:test_keywords_cn.py


示例4: test_print

def test_print():
    """
    test output statement and string types
    """
    assert convertor("印出 'hello'") == "print 'hello'"
    assert convertor('印出 "hello"') == 'print "hello"'
    assert convertor("""印出 'hello'""") == "print 'hello'"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:7,代码来源:test_keywords_tw.py


示例5: test_is

def test_is():
    """
    test is, is not statement
    """
    assert convertor("4 為 4") == ("4 is 4")
    assert convertor("4 是 4") == ("4 is 4")
    assert convertor("4 不是 2") == ("4 is not 2")
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:7,代码来源:test_controlflow_cn.py


示例6: test_if

def test_if():
    """
    test if, elif, else
    """
    assert convertor("如果 a: 略過") == "if a: pass"
    assert convertor("如果 a: 略過; 否則: 略過") == "if a: pass; else: pass"
    assert convertor("如果 a: 略過; 假使 b: 略過; 否則: 略過") == \
                    "if a: pass; elif b: pass; else: pass"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:8,代码来源:test_controlflow_tw.py


示例7: test_boolean

def test_boolean():
    """
    test boolean type
    """
    assert convertor("n = 真") == "n = True"
    assert convertor("p = 假") == "p = False"
    assert convertor("q = 实") == "q = True"
    assert convertor("r = 虛") == "r = False"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:8,代码来源:test_types_cn.py


示例8: test_string

def test_string():
    """
    same as print test
    """
    assert convertor("s.开头为('he')") == "s.startswith('he')"
    assert convertor("s.结尾为('he')") == "s.endswith('he')"
    assert convertor("items = 'zero one two three'.分离()") == "items = 'zero one two three'.split()"
    assert convertor("''.连接(s)") == "''.join(s)"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:8,代码来源:test_types_cn.py


示例9: test_list

def test_list():
    """
    test list type
    """
    assert convertor("列表((1,2,3,4)) == [1,2,3,4]") == "list((1,2,3,4)) == [1,2,3,4]"
    assert convertor("a = []; a.加入(2); 宣告 a == [2]") == "a = []; a.append(2); assert a == [2]"
    p = "h,e,l,l,o"
    assert convertor('p.分离(",")') == 'p.split(",")'
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:8,代码来源:test_types_cn.py


示例10: test_bool

def test_bool():
    """
    test boolean type
    """
    assert convertor("布尔(1)") == "bool(1)"
    assert convertor("n 是 真") == "n is True"
    assert convertor("p 为 假") == "p is False"
    assert convertor("q 不是 实") == "q is not True"
    assert convertor("r 不为 虛") == "r is not False"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:9,代码来源:test_types_cn.py


示例11: test_operators

def test_operators():
    """
    test operators
    
    >>> 1 == 1
    True
    """
    assert convertor("a 等於 b") == "a == b"
    assert convertor("a 不等於 b") == "a != b"
开发者ID:Abelisme,项目名称:zhpy,代码行数:9,代码来源:test_keywords_tw.py


示例12: test_convertor

def test_convertor():
    """
    test convertor
    """
    rev_annotator()
    assert convertor("印出 'hello'") == "print 'hello'" 
    assert python_convertor("print 'hello'") == ("印出 'hello'")
    assert python_convertor(convertor("印出 'hello'")) == ("印出 'hello'")
    # check if variable convert correctly, not a python valid syntax
    assert python_convertor(convertor("打出 '''哈囉'''")) == ("打出 '''哈囉'''")
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:10,代码来源:test_api.py


示例13: test_print

def test_print():
    """
    test output statement and string types
    
    >>> print "hello"
    hello
    """
    assert convertor("打印 'hello'") == "print 'hello'"
    assert convertor('打印 "hello"') == 'print "hello"'
    assert convertor("""打印 'hello'""") == "print 'hello'"
开发者ID:Abelisme,项目名称:zhpy,代码行数:10,代码来源:test_keywords_cn.py


示例14: test_list

def test_list():
    """
    test list type
    
    >>> list((1,2,3,4)) == [1,2,3,4]
    True
    """
    assert convertor("列表((1,2,3,4)) == [1,2,3,4]") == \
                    "list((1,2,3,4)) == [1,2,3,4]"
    assert convertor("a = []; a.加入(2); 申明 a == [2]") == \
                    "a = []; a.append(2); assert a == [2]"
    p = "h,e,l,l,o"
    assert convertor('p.分離(",")') == 'p.split(",")'
开发者ID:Abelisme,项目名称:zhpy,代码行数:13,代码来源:test_types_tw.py


示例15: push

 def push(self, line):
     self.buffer.append(line)
     source = "\n".join(self.buffer)
     more = self.runsource(convertor(source), self.filename)
     if not more:
         self.resetbuffer()
     return more
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:7,代码来源:interpreter.py


示例16: test_enumerate

def test_enumerate():
    """
    test enumerate
    
    """
    assert convertor("取 (index, item) 在 列举(items): 打印 index, item") == \
                    "for (index, item) in enumerate(items): print index, item"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:7,代码来源:test_buildin_modules_cn.py


示例17: test_string

def test_string():
    """
    same as print test
    
    >>> s = "hello.py"
    >>> s.startswith('he')
    True
    >>> s.endswith('py')
    True
    >>> s = ['one', 'two']
    >>> ''.join(s)
    'onetwo'
    """
    assert convertor("s.开头为('he')") == "s.startswith('he')"
    assert convertor("s.结尾为('py')") == "s.endswith('py')"
    assert convertor("items = 'zero one two three'.分离()") == "items = 'zero one two three'.split()"
    assert convertor("''.连接(s)") == "''.join(s)"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:17,代码来源:test_types_cn.py


示例18: test_set

def test_set():
    """
    test set type
    
    >>> set([1,2,3,4]) == set([1, 2, 3, 4])
    True
    """
    assert convertor("集合([1,2,3,4]) == set([1, 2, 3, 4])") == \
                    "set([1,2,3,4]) == set([1, 2, 3, 4])"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:9,代码来源:test_types_cn.py


示例19: test_tuple

def test_tuple():
    """
    test tuple type
    
    >>> tuple([1,2,3,4]) == (1,2,3,4)
    True
    """
    assert convertor("数组([1,2,3,4]) == (1,2,3,4)") == \
                    "tuple([1,2,3,4]) == (1,2,3,4)"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:9,代码来源:test_types_cn.py


示例20: test_dict

def test_dict():
    """
    test dict type
    
    >>> dict(a=1, b=2) == {'a':1, 'b':2}
    True
    """
    assert convertor("字典(a=1, b=2) == {'a':1, 'b':2}") == \
                    "dict(a=1, b=2) == {'a':1, 'b':2}"
开发者ID:BGCX261,项目名称:zhpy-svn-to-git,代码行数:9,代码来源:test_types_cn.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.get_db_session函数代码示例发布时间:2022-05-26
下一篇:
Python zhelpers.dump函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap