Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 不显示页面_Python_Python 3.x - Fatal编程技术网

Python 不显示页面

Python 不显示页面,python,python-3.x,Python,Python 3.x,我试图弄明白为什么当我尝试加载这个页面时,我得到的只是一个白色屏幕。我不确定我的应用程序编码是否正确。有人能解释一下我做错了什么,这样我就可以修复它,让它至少在我的浏览器中显示一些东西 class Page(object): def __init__(self): self.header = """ <!DOCTYPE HTML> <html> <head> <title>New York Yank

我试图弄明白为什么当我尝试加载这个页面时,我得到的只是一个白色屏幕。我不确定我的应用程序编码是否正确。有人能解释一下我做错了什么,这样我就可以修复它,让它至少在我的浏览器中显示一些东西

class Page(object):
    def __init__(self):

        self.header = """
<!DOCTYPE HTML>
<html>
    <head>
        <title>New York Yankees Starting Lineup/title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
    </head>
    <body>
        """

        self.content = ""

        self.footer = """
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    </body>
</html>
     """

    def print_out(self):
        template = self.header + self.content + self.footer
        template = template.format(**locals())
        return template

class ContentPage(Page):
    def __init__(self):
        self.player_data = ''
        Page.__init__(self)
        self.player_data = '''
        <div>
        Name: + player_data.player_name
        Position: + player_data.position
        Bats: + player_data.bats
        Throws: + player_data.throws
        Batting Average: + player_data.avg
        Home Runs: + player_data.hr
        </div>'''

    def print_out(self):
        return self.header + self.content + self.player_data + self.footer
类页面(对象):
定义初始化(自):
self.header=“”
纽约洋基队首发阵容/冠军>
"""
self.content=“”
self.footer=“”
"""
def打印输出(自):
模板=self.header+self.content+self.footer
template=template.format(**locals())
返回模板
类内容页(第页):
定义初始化(自):
self.player_数据=“”
第页。\uuuuu初始\uuuuuuuuuu(自我)
self.player_数据=“”
名称:+player\u data.player\u名称
位置:+player\u data.Position
蝙蝠:+player_data.Bats
投掷:+player\u data.Throws
击球平均值:+player_data.avg
本垒打:+player\u data.hr
'''
def打印输出(自):
返回self.header+self.content+self.player\u数据+self.footer

更新:我仍然在为这个问题挣扎。有没有人能帮我弄清楚发生了什么事以及如何解决?欢迎任何帮助。

self.content
被初始化为空字符串,并且永远不会更改
self.player\u数据可能是您希望看到的,但是它没有在任何地方使用(尽管它的名称出现在分配给
self.player\u数据的字符串中)


一种解决方案是为
内容页面
分配
self.player_数据
,而不是
初始化
中的
self.player_数据
self.player_数据
看起来应该是关于某个玩家的信息,而不是显示该数据的模板。

我如何告诉内容显示玩家_数据?