在 Python中使用 cout << 'Hello,world!' << endl

来源:互联网 发布:ubuntu安装软件包 编辑:程序博客网 时间:2024/05/02 00:29

import sys

class ostream:
    def __init__(self,file):
        self.file = file

    def __lshift__(self,obj):
        self.file.write(str(obj));
        return self

cout = ostream(sys.stdout)
cerr = ostream(sys.stderr)
endl = '/n'


age = 23
name = 'albert'

cout << 'Hello,world!' << endl

cout << 'Name:' << name << endl << 'Age:' << age << endl

原创粉丝点击