常见的cli输入助手函数和string/arg转换

input-helper的Python项目详细描述


安装

% pip3 install input-helper

用法

In[1]:importinput_helperasihIn[2]:real_args=ih.string_to_set('arg1, arg2, arg3')In[3]:real_val=ih.from_string('true')In[4]:response=ih.user_input('type some input, human')In[5]:selected=ih.make_selections(list_of_items)In[6]:seconds=ih.timestamp_to_seconds('1h22m33s')In[7]:urls=ih.get_all_urls('some-file-with-urls.txt','https://blah.net')In[8]:frompprintimportpprintIn[9]:mm=ih.matcher.MasterMatcher(debug=True)In[10]:pprint(mm('@handle1 and @handle2 here are the #docs you requested https://github.com/kenjyco/input-helper/blob/master/README.md')){'_key_matcher_dict':{'mention_list':'MentionMatcher','non_url_text':'NonUrlTextMatcher','tag_list':'TagMatcher','text':'IdentityMatcher','url_details_list':'UrlDetailsMatcher','url_list':'UrlMatcher'},'mention_list':['handle1','handle2'],'non_url_text':'@handle1 and @handle2 here are the #docs you requested','tag_list':['docs'],'text':'@handle1 and @handle2 here are the #docs you requested ''https://github.com/kenjyco/input-helper/blob/master/README.md','url_details_list':[{'domain':'github.com','filename_prefix':'github.com--kenjyco--input-helper--blob--master--README.md','full_url':'https://github.com/kenjyco/input-helper/blob/master/README.md','path':{'full_path':'/kenjyco/input-helper/blob/master/README.md','uri':'/kenjyco/input-helper/blob/master/README.md'},'protocol':'https'}],'url_list':['https://github.com/kenjyco/input-helper/blob/master/README.md']}In[11]:ih.user_input_fancy()input>gotohttps://github.com/kenjycoforagoodtime#learning stuffOut[11]:{'line_orig':'go to https://github.com/kenjyco for a good time #learning stuff','non_url_text':'go to for a good time #learning stuff','tag_list':['learning'],'url_list':['https://github.com/kenjyco']}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java传递实现接口的内部类   java为什么managedbean方法在post请求中的过滤器调用之前调用   java Android应用程序在Android M,O上崩溃,登录A/libc时出错:tid 17938中的致命信号11(SIGSEGV),代码2,故障地址0x343a2944   java JPA存储库。findByAll()返回null,但数据库中存在所有内容   用于发送电子邮件的java Ant脚本   Java小程序HTML页面发生了奇怪的事情   在Postman的请求正文中传递多个JSON数据,并使用Jersy(JXRS)进入Java Rest API   无法强制转换java DAO类   10分钟后重新连接java   正则表达式如何在java中选择字符串直到某个字符   java我的输出有一些问题   Objective中的java时间段   java如何在新屏幕上基于按钮单击在webview中打开url   java哪个selenium版本与Firefox ESR 45.2.0兼容   java无法使用Apache Camel 3.1.0将XML转换为JSON