【发布时间】:2009-12-08 04:34:32
【问题描述】:
#!/usr/bin/env python
import os, sys, subprocess, time
while True:
print subprocess.call("xsel", shell=True);
time.sleep(1);
每 1 秒从剪贴板获取一个条目并打印一次。
结果:
copied0
entry0
from0
clipboard0
我不知道为什么它返回最后的 0,但它显然阻止了我使用字符串条(int 没有条),因此 0 使字符串成为整数?
如何从上面结果中的 python 字符串中去除最后的 0?
我是一名转换为 python 的 BASH 脚本编写者。
【问题讨论】:
标签: python string integer subprocess popen