Youtube在Django中搜索 - > manage.py:错误:无法识别的参数:shell

时间:2016-06-01 22:33:58

标签: python django youtube oauth-2.0

Youtube Code

如果我在IDLE中使用此代码 - 一切正常,但是当我在Django项目中使用时,即通过python manage.py shell运行时,我会看到下一个:

usage: manage.py [--auth_host_name AUTH_HOST_NAME] [--noauth_local_webserver]
                 [--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
                 [--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
                 [--max-results MAX_RESULTS]
manage.py: error: unrecognized arguments: shell

我发现错误发生在第args = argparser.parse_args()行,但无法找到解决方法。有人可以帮忙吗?

修改 一旦我启动了shell,我就调用youtube_search(),但是当解释器执行行args = argparser.parse_args()时,shell关闭,我看到上面的消息。

1 个答案:

答案 0 :(得分:0)

由于我不需要将任何参数从命令行传递给函数,所以我只是将其删除:

function showDiv(that) {
  var len = document.getElementsByTagName('div').length;
  for (var i = 0; i < len; i++) {
       document.getElementsByTagName('div')[i].style.visibility = "hidden";
       document.getElementsByTagName('div')[i].style.height = "0px";
       document.getElementsByTagName('div')[i].style.overflow = "hidden";
  }
  var val =  that.value;
  document.getElementById(val).style.visibility = "visible";
  document.getElementById(val).style.height = "10px";
  document.getElementById(val).style.overflow = "visible";
}

并将我需要的参数直接传递给函数:

    Hope this will help you:
        <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/relatively"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d15400"
android:orientation="vertical"
android:weightSum="1" >

<LinearLayout
    android:id="@+id/Linear_ad"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
     />
   <LinearLayout/>



 AdView adview;
LinearLayout linearads;
private AdBannerListener adBannerListener;
oncreate:
 setAdvertise();

 private void setAdvertise()
{
    try{

        try{



            layout=(LinearLayout)findViewById(R.id.Linear_ad);


            adview= new AdView(CAboutActivity.this);
            adview.setAdSize(AdSize.BANNER);
            adview.setAdUnitId("adUnit id");
            adview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
            layout.addView(adview);
            adview.loadAd(new AdRequest.Builder().build());
            //linear_ad
        }catch (Exception e) {
            // TODO: handle exception
        }
        adview.setAdListener(new AdListener() {
            @Override
            public void onAdFailedToLoad(int errorCode) {
                // TODO Auto-generated method stub
                try {
                    Log.d("On Fail called", "Ad");
                    layout.setVisibility(View.GONE);
                    super.onAdFailedToLoad(errorCode);
                }catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            @Override
            public void onAdLoaded() {
                // TODO Auto-generated method stub
                Log.d("On Load called","Ad");
                layout.setVisibility(View.VISIBLE);
                super.onAdLoaded();
            }
        });
    }catch (Exception e) {
        // TODO: handle exception
    }
}

并在此处进行更改:

  argparser.add_argument("--q", help="Search term", default="Google")
  argparser.add_argument("--max-results", help="Max results", default=25)
  args = argparser.parse_args()