简体   繁体   English

使用 xdg Linux 命令的 Python URL 调用

[英]Python URL call using xdg Linux command

I have been trying to get this simple url call Linux command to run as a python script.我一直试图让这个简单的 url 调用 Linux 命令作为 python 脚本运行。 However, I keep getting an error for too many arguments in the system() module.但是,由于 system() 模块中的参数过多,我不断收到错误消息。 Is there is easy fix still using this technique?是否有简单的修复仍在使用这种技术?

import sys
import os
g = str(input('enter search '))
os.system('xdg-open https://',g)

format the command as a single string instead of 2 parameters将命令格式化为单个字符串而不是 2 个参数

import sys 
import os

search = str(input('enter search')) 
os.system(f'xdg-open https://{search}')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM