pycharm里面的emmet如何才能在python文件里面使用?
大家讲道理
大家讲道理 2017-04-18 09:19:05
0
2
518
from flask import Flask
from flask import request
app = Flask(__name__)

@app.route('/')
def index():
    user_agent = request.headers.get('User-Agent')
    return '<p>hello world</p><span>your browser agent is %s</span>' % user_agent
if __name__ == '__main__':
    app.run(debug=True)

写python代码里面有时候需要写html片段, 但是pycharm似乎在python文件里面不支持使用emmet, 请问如何设置?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
左手右手慢动作

Theoretically you should split the html into the template
If you have to write html in the py file, you can write it like this, the readability will be much better

user_agent = request.headers.get('User-Agent')

html = """
    <p>hello world</p>
    <span>your browser agent is {user_agent}</span>
""".format(user_agent=user_agent)

return html
大家讲道理

You should use the flask template and edit it with emmet in the template file

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template