擅长:python、mysql、java
<p>我不清楚<code>telegraph</code>模块为什么用空格替换换行符。在这种情况下,禁用此功能似乎是合理的</p>
<pre><code>import subprocess
import re
import telegraph
from telegraph import Telegraph
telegraph.utils.RE_WHITESPACE = re.compile(r'([ ]{10})', re.UNICODE)
telegraph = Telegraph()
telegraph.create_account(short_name='1111')
tmp = subprocess.run("/usr/sbin/arp",
capture_output=True,
text=True,
shell=True).stdout
response = telegraph.create_page(
'Random',
html_content = '<pre>' + tmp + '</pre>'
)
print('https://telegra.ph/{}'.format(response['path']))
</code></pre>
<p>将输出</p>
<p><a href="https://i.stack.imgur.com/KUf3C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KUf3C.png" alt="arp output formatted for telegraph"/></a></p>
<p>这接近于实际的格式化<code>arp</code>输出</p>