Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/325.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.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 如何获取输入数据并以预先编码的HTML格式打印输入_Python_Algorithm_Input_Output - Fatal编程技术网

Python 如何获取输入数据并以预先编码的HTML格式打印输入

Python 如何获取输入数据并以预先编码的HTML格式打印输入,python,algorithm,input,output,Python,Algorithm,Input,Output,我目前使用txt编辑器修改发送给供应商的电子邮件通讯代码 这是乏味的,但是它允许我创建一个html表,编辑它并发送给客户 我认为编写一些代码可能会更容易一些,这样我就可以键入输入,然后程序会给我和输出格式化的HTML代码,以便复制和粘贴到我的时事通讯电子邮件服务中 这是我目前拥有的,但它没有打印带有必要输入值的代码。 这就是我目前所拥有的 """ VAN_REEFER = input("VAN OR REEFER OR POWER ONLY?") PICKUP_LOCATION = input(

我目前使用txt编辑器修改发送给供应商的电子邮件通讯代码

这是乏味的,但是它允许我创建一个html表,编辑它并发送给客户

我认为编写一些代码可能会更容易一些,这样我就可以键入输入,然后程序会给我和输出格式化的HTML代码,以便复制和粘贴到我的时事通讯电子邮件服务中

这是我目前拥有的,但它没有打印带有必要输入值的代码。 这就是我目前所拥有的

"""
VAN_REEFER = input("VAN OR REEFER OR POWER ONLY?")
PICKUP_LOCATION = input("WHERE DOES THIS PICKUP?")
PICKUP_TIME = input("WHAT TIME DOES THIS PICKUP?")
DROP_LOCATION = input("WHERE DOES THIS DROP?")
DROP_TIME = input("WHAT TIME DOES THIS DROP?")
ACCEPT_NOW = input("ACCEPT NOW RATE")

print ("""<tr>
<td>(VAN_REEFER)</td>
<td>(PICKUP_LOCATION)<br><b>(PICKUP_TIME)</b></br></td>
<td>(DROP_LOCATION)<br><b>DROP_TIME</b></br></td>
<TD><B>(ACCEPT_NOW)</B></TD>
<td>
<a href="mailto:Dispatch%40MYEMAIL.com?subject=%20%F0%9F%90%A2%20-%20%20-
PICK-
(PICKUP_TIME)
%20-%20-
(PICKUP_LOCATION)
%20
TO
%20-
(DROP_TIME)
-%20
(DROP_LOCATION)
DROP-
%20-%20
(VAN_REEFER)
%0A&amp;body=
I%20HAVE%20A%20TRUCK%20FOR%20THIS%20LOAD-
%20%0A
MY%20RATE%20IS-
%20%0A
THIS%20IS%20MY%20ETA%20TO%20PICKUP%20THIS%20LOAD-
%20%0A
THIS%20IS%20MY%20PHONE%20NUMBER-
%20%0A">Take a look at template engines such as Jinja or mako. 

You can write html templates like this (example is from this Jinja tutorial):

  <p>My string: {{my_string}}</p>
  <p>Value from the list: {{my_list[3]}}</p>
  <p>Loop through the list:</p>
  <ul>
    {% for n in my_list %}
    <li>{{n}}</li>
    {% endfor %}
  </ul>
“”“
VAN_冷藏车=输入(“VAN或冷藏车或仅电源?”)
皮卡位置=输入(“皮卡在哪里?”)
拾取时间=输入(“此拾取时间是几点?”)
DROP_LOCATION=input(“这个放置在哪里?”)
DROP\u TIME=input(“此操作何时停止?”)
立即接受=输入(“立即接受费率”)
打印(“”)
(范努里弗)
(拾取位置)
(拾取时间)
(放置位置)
放置时间
(现在接受你) 看一看像或

您可以这样编写html模板(示例来自):

我的字符串:{{My_string}

列表中的值:{{my_list[3]}

循环浏览列表:

    {%n在我的_列表%}
  • {{n}}
  • {%endfor%}
模板引擎将动态替换双花括号中给定的变量
{{}
。您甚至可以使用
{%…%}
创建循环和条件