python - 在 python 中的命令中添加定义
问题描述
我有 c 是一个定义(下面的代码)。如何将它添加到命令中以在 python 中运行?谢谢你。
text_file = open("lastline.txt", "w")
n = text_file.write(last_line)
text_file.close()
with open('lastline.txt', 'r') as f:
c = f.read(12)
print("Detected disk identifier as", c)
os.system("diskutil unmount c")
解决方案
os.system("diskutil unmount %s", c)
推荐阅读
- ruby - 代码块中的两条垂直线和 super.select 是什么意思?
- c++ - 在可变参数模板的情况下如何应用模板模板参数
- java - MALLET 无法恢复实例列表
- angular - 被调用但未在角度测试中显示的功能
- python - 从源代码字符串中提取 Python 函数源文本
- java - 如何强制 Android ListView 以更少(滚动动作/拖动)更改/更新列表项位置?
- javascript - 有没有办法通过 JavaScript 信任 HTTPS 证书?
- python - 将数据添加到 most_common() 列表?
- c - 为什么我的 pthread_t 指针数组会导致 pthread_create 出现段错误,但对数组中 pthread_t 的引用却没有
- php - 如何对 $_POST $_FILES 文件进行 base 64 编码