[英]Print the results of a python file in bash on several lines
我有一个for循环的python文件。
说文件python.py
:
for i in "Hello"
print(i, '\n')
我正在.coffee
命令在.coffee
文件中运行此代码
command: "export LANG=en_CA.UTF-8; python3 folder/python.py"
refreshFrequency: 1000*60
style: """
top: 245px
right: 0px
width: 240px
height: 600px
margin-left: -(@width / 2)
overflow: hidden
.content
background: rgba(#fff, 0.5)
color: #152033
margin-left: 3px
font-size: 18px
font-family: Ubuntu
text-align: left
.title
background: rgba(#fff, 0.5)
color: #152033
font-size: 40px
font-family: Ubuntu
text-align: center
bg-blur = 10px
.bg-slice
position: absolute
top: -(bg-blur)
left: -(bg-blur)
width: 100% + 2*bg-blur
height: 100% + 2*bg-blur
-webkit-filter: blur(bg-blur)
"""
render: (output) -> """
<canvas class='bg-slice'></canvas>
<div class='title'>Inbox:</div>
<div class='content'>#{output}</div>
"""
然后,代码在一行上输出Hello
。 如何获取此代码以输出类似内容?
H
e
l
l
o
我确实在python的打印命令中放入了'\\n'
。
您的python代码有问题,没有冒号: for循环之后。 同样也不需要在每一行写“ \\ n”,python会自动将每个字母移到新行:
#! /usr/bin/python
for i in "Hello":
print(i)
将其放入您的python脚本中,然后再次编译您的coffee脚本,它的输出为:
H
e
l
l
o
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.