python beautifulsoup find_all方法返回空列表

网页代码如下:
图片说明
我的python代码:

cards2 = soup.find_all('div',class_='product ')

class的属性值我是复制粘贴过来的,find其他的div上没有问题,可是就是这个总是给我返回空列表

图片说明
网址为:https://list.tmall.com/search_product.htm?q=%CA%D6%BB%FA

请大神们帮忙看看是怎么回事

0

4个回答

这个div的内容是不是ajax异步加载的。这样你查找的时候,可能数据还没有填充进来

2

#!usr/bin/env python
#_*_ coding:utf-8 *
import requests
from bs4 import BeautifulSoup
import lxml
url='https://list.tmall.com/search_product.htm?q=%CA%D6%BB%FA'
html=requests.get(url)
res=html.text
print(res)
soup=BeautifulSoup(res,"lxml")
cards2 = soup.find_all('div',attrs={'class':"product "})
print('------------------------')
print(cards2)

看不了你的网页:打开是登录窗口,你的网站是天猫网,很有可能ajax异步加载,

0

用class找不了,换个别的比如data-atp就行了,我也不知道原理,希望有人知道了能解答一下。

0
QBL_user
Zerone龍 因为class是预留关键字,想要匹配class得写成“class_”就行了,就是后面加个下划线
7 个月之前 回复

1、class="product " 你复制的内容不对,里面还有空格,把整个双引号全复制
2、with req.urlopen(request) as respones:
data=respones.read()
data=open(data,'w',encoding='utf-8')#这个为了防止解码问题

3、 root=bs4.BeautifulSoup(data,'html.parser')
print(root)#解码问题解决
4、后面就正常爬取
card=root.find_all('div',class_="product ")
print(card)
问题都这么久了不知道能帮上忙

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python BeautifulSoup find_all 问题
用python爬下一个网页,将其弄成BeautifulSoup Object之后,n1. ptint bsObj 可以输出中文内容n2. print bsObj.find__all之后,输出的是unicode编码的内容,请问该怎么处理呢?_
BeautifulSoup使用find_all方法乱码问题
   request = urllib2.Request(url,headers = headers)    response = urllib2.urlopen(request)    content = response.read()    soup = BeautifulSoup(content,'html.parser',from_encoding='utf-8')    node = s...
adb devices 返回空列表
手机连接上电脑后,设备管理器上能看到Android Phonern但执行adb devices 返回空列表rn启动91手机助手后,adb devices 能返回我的手机rn请问为什么,如果解决,不需要启动91手机助手也能正常执行adb命令
返回空
在组件中设置getname("name");rn return 返回变量作用是什么?
求助,findViewById()方法返回空
最近在测试android文件读写的时候遇到的一个问题:findviewbyid()方法总是返回null.rn先贴源代码:rn主activity:rnpackage com.android.file;rnrnimport java.io.FileNotFoundException;rnimport java.io.IOException;rnrnimport android.app.Activity;rnimport android.content.Context;rnimport android.os.Bundle;rnimport android.view.LayoutInflater;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnimport android.widget.Button;rnimport android.widget.EditText;rnimport android.widget.TextView;rnimport android.widget.Toast;rnrnimport com.android.filecontrol.FileService;rnrnpublic class AndroidfileActivity extends Activity rn /** Called when the activity is first created. */rn private Button saveBtn, getBtn;rnrn @Overridern public void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.main);rn rn saveBtn = (Button) findViewById(R.id.button1);rn getBtn = (Button) findViewById(R.id.button2);rn saveBtn.setOnClickListener(onclick);rn getBtn.setOnClickListener(onclick);rn rnrn public OnClickListener onclick = new OnClickListener() rn FileService fileService = new FileService();rn [color=#993300]EditText editfileEditText = (EditText) findViewById(R.id.edittext1);[/color]rn EditText editcontentEditText = (EditText) findViewById(R.id.edittext2);rn TextView textview = (TextView)findViewById(R.id.textresult);rn @Overridern public void onClick(View v) rn // TODO Auto-generated method stubrn switch (v.getId()) rn case R.id.button1:rn try rn fileService.WriteFile(AndroidfileActivity.this.openFileOutput(rn editfileEditText.getText().toString(), MODE_APPEND),rn editcontentEditText.getText().toString());rn Toast.makeText(AndroidfileActivity.this, "保存成功!", Toast.LENGTH_LONG);rn catch (FileNotFoundException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (IOException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn break;rn case R.id.button2:rn try rn String contentString = fileService.ReadFile(AndroidfileActivity.this.openFileInput(editfileEditText.getText().toString()));rn textview.setText(contentString);rn catch (FileNotFoundException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (IOException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn break;rn rn rn ;rnrnrnlayout下的main.xmlrnrnrnrn rn rnrn rn rnrn rnrn rn rn rnrnrnrn还有R.javarn/* AUTO-GENERATED FILE. DO NOT MODIFY.rn *rn * This class was automatically generated by thern * aapt tool from the resource data it found. Itrn * should not be modified by hand.rn */rnrnpackage com.android.file;rnrnpublic final class R rn public static final class attr rn rn public static final class drawable rn public static final int ic_launcher=0x7f020000;rn rn public static final class id rn public static final int button1=0x7f050005;rn public static final int button2=0x7f050007;rn public static final int editText1=0x7f050003;rn public static final int editText2=0x7f050006;rn public static final int edittext1=0x7f050001;rn public static final int edittext2=0x7f050004;rn public static final int textView1=0x7f050000;rn public static final int textView2=0x7f050002;rn public static final int textresult=0x7f050008;rn rn public static final class layout rn public static final int main=0x7f030000;rn rn public static final class string rn public static final int app_name=0x7f040001;rn public static final int hello=0x7f040000;rn rnrnrn错误:rn11-27 09:20:39.828: E/AndroidRuntime(342): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)rn11-27 09:20:39.828: E/AndroidRuntime(342): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)rn11-27 09:20:39.828: E/AndroidRuntime(342): at android.app.ActivityThread.access$1500(ActivityThread.java:117)rn11-27 09:20:39.828: E/AndroidRuntime(342): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)rn11-27 09:20:39.828: E/AndroidRuntime(342): at android.os.Handler.dispatchMessage(Handler.java:99)rn11-27 09:20:39.828: E/AndroidRuntime(342): at android.os.Looper.loop(Looper.java:123)rn11-27 09:20:39.828: E/AndroidRuntime(342): at android.app.ActivityThread.main(ActivityThread.java:3683)rn11-27 09:20:39.828: E/AndroidRuntime(342): at java.lang.reflect.Method.invokeNative(Native Method)rn11-27 09:20:39.828: E/AndroidRuntime(342): at java.lang.reflect.Method.invoke(Method.java:507)rn11-27 09:20:39.828: E/AndroidRuntime(342): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)rn11-27 09:20:39.828: E/AndroidRuntime(342): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)rn11-27 09:20:39.828: E/AndroidRuntime(342): at dalvik.system.NativeStart.main(Native Method)rn11-27 09:20:39.828: E/AndroidRuntime(342): Caused by: java.lang.NullPointerExceptionrn11-27 09:20:39.828: E/AndroidRuntime(342): at android.app.Activity.findViewById(Activity.java:1647)rn11-27 09:20:39.828: E/AndroidRuntime(342): at com.android.file.AndroidfileActivity$1.(AndroidfileActivity.java:36)rn11-27 09:20:39.828: E/AndroidRuntime(342): at com.android.file.AndroidfileActivity.(AndroidfileActivity.java:34)rn11-27 09:20:39.828: E/AndroidRuntime(342): at java.lang.Class.newInstanceImpl(Native Method)rn11-27 09:20:39.828: E/AndroidRuntime(342): at java.lang.Class.newInstance(Class.java:1409)rn11-27 09:20:39.828: E/AndroidRuntime(342): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)rn11-27 09:20:39.828: E/AndroidRuntime(342): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)rn11-27 09:20:39.828: E/AndroidRuntime(342): ... 11 morernrn我在网上搜了很多资料,说错误的原因大概有两种:rn1.findviewbyid()方法用在setcontentview()方法之前。我仔细查看了代码排除了这个原因。rn2.clean工程然后重建工程。试了无数遍还是不行,最后把工程全部删了之后重新建了一个工程把代码copy进去之后问题依然如故。rn希望遇到过此问题的大虾们给点建议,我记得之前曾经遇到过这个问题,当时以为是R.java文件没有同步,就把main.xml里面的东西删掉重新写了一遍就好了,但这次不管用了。rn另外代码里面还有其他的控件比如button的获取就没有问题,为什么偏偏EditView就不行了?
python爬虫(三):BeautifulSoup 【5. 信息提取(find_all)】
find_all: <>.find_all(name, attrs, recursive, string, **kwargs) ∙ name : 对标签名称的检索字符串 ∙ attrs: 对标签属性值的检索字符串,可标注属性检索 ∙ recursive: 是否对子孙全部检索,默认True ∙ string: <>…</>中字符串区域的检索字符串   ...
SqlCommand.ExecuteScalar 方法 返回空引用?
MSDN中的说明:rnC# rnpublic override Object ExecuteScalar ()rnrn返回值rn结果集中第一行的第一列或空引用(如果结果集为空)。 rnrn典型的 ExecuteScalar 查询可以采用类似于下面的 C# 示例的格式:rncmd.CommandText = "SELECT COUNT(*) FROM dbo.region";rn Int32 count = (Int32) cmd.ExecuteScalar();rnrnrn但我今天使用rnrnselect sum(zf) from oracleTable where ......的语句,返回的对象obj在(decimal)obj时,发生“指定的转换无效异常”,调试时发现obj为obj,?obj==null返回false,但如果select返回值>0时就正常,怪事。rnrn如何判断obj为空,并转换为0呢?
Android ProgressDialog返回空
想要做一个进程对话框用在JSON捕捉数据时。但是返回空值。代码:rnrnclass NetWork extends AsyncTask> rnrn private ProgressDialog pd;rn public void Network() rn try rn ServiceStations service = new ServiceStations();rn service.load(WorkshopActivity.this.getApplicationContext());rn catch (IOException e) rn // do nothingrn e.printStackTrace();rn catch (JSONException e) rn // do nothingrn e.printStackTrace();rn rn pd = new ProgressDialog(WorkshopActivity.this);rn pd.setMessage("Load");rn pd.setCancelable(false);rn pd.setCanceledOnTouchOutside(false);rn rn @Overridern public ArrayAdapter doInBackground(Void... params) rn @SuppressWarnings( "unchecked", "rawtypes" )rn final ArrayAdapter areaAdapter = new ArrayAdapter(rn WorkshopActivity.this, android.R.layout.simple_list_item_1,rn ServiceStations.getAreaList());rn return areaAdapter;rn rn @Overridern protected void onPreExecute() rn super.onPreExecute();rn try rn pd.show(); // this returns nullrn catch (NullPointerException e) rn // TODO: handle exceptionrn e.printStackTrace();rn rn rn @Overridern public void onPostExecute(ArrayAdapter areaAdapter) rn /*rn * if (dialog.isShowing()) dialog.dismiss(); rn */rn list = (ListView) findViewById(R.id.listWorkshopCity);rn list.setAdapter(areaAdapter);rn adapter = areaAdapter;rn rn rnrnstacktrace:rnrn 07-15 04:34:15.006: W/System.err(3393): java.lang.NullPointerExceptionrn 07-15 04:34:15.006: W/System.err(3393): at com.jatismobile.iklaim.activities.WorkshopActivity$NetWork.onPreExecute(WorkshopActivity.java:74)rn 07-15 04:34:15.026: W/System.err(3393): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)rn 07-15 04:34:15.026: W/System.err(3393): at android.os.AsyncTask.execute(AsyncTask.java:534)rn 07-15 04:34:15.036: W/System.err(3393): at com.jatismobile.iklaim.activities.WorkshopActivity.onCreate(WorkshopActivity.java:102)
ExtractShortPathName怎么会返回空?
form上只有一个edit和一个button,rn单击button执行:rnedit1.Text:=ExtractShortPathName('C:\Program Files\Borland\Delphi\Bin\Delphi32.exe');rn但edit1中显示居然为空?rn请问为什么?rn多谢!rn
LoadBitmap返回空句柄
有LoadBitmap加载资源文件里面的位图结果返回空句柄,用GetLastError查看错误结果是ERROR 87,参数不正确,但如果定义图标资源可以正确加载,求高人指点rn.RC文件rn#include "resource.h"rnICO ICON "MAIN.ICO"rnBMP BITMAP "1.bmp"rnresource.hrn#define BMP 1rn#define ICO 2rn.CPP文件(有incllude"resoruce.h")rn在WM_CREATE里面加载位图rncase WM_CREATE:rn hBitmap=LoadBitmap(g_hInstance,MAKEINTRESOURCE(BMP));rn error1=GetLastError();rn LoadIcon(g_hInstance,MAKEINTRESOURCE(ICO));rn error2=GetLastError();rn break;rnerror1=87,error2=0
为何get_fs_names返回空?
我想启动ramdisk的内核rnrn结果发现内核初始化到rnrnprepare_namespace()->mount_root()->mount_block_root()-->get_fs_names 返回的是空rnrn也就是说,可能module_init(init_ext2_fs)出错了rnrn但是这种module_init的错误,根本就没办法跟踪吧rnrn怎么办呢 谁给点意见 谢谢rnrn
unserialize 返回空
[code=PHP]rna.php rnrnfunction get_data()rn $staff = new staff();rn $list = $staff->get_staff_list();rn echo serialize($list);rnrnrnrn[/code]rnrn[code=PHP]rnfunction get_staff($url='',$posts='') rn global $config;rn $url = $config['staff'];rn $ch = curl_init($url);rn curl_setopt($ch, CURLOPT_HEADER, 0);rn curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);rn curl_setopt($ch,CURLOPT_VERBOSE,1);rnrn $contents = curl_exec($ch); rn curl_close($ch);rn //echo $contents;rn return unserialize($contents );rnrn $contents有值 rn unserialize($contents );输出就什么也没有了rnrn rnrn rn[/code]
动态数组返回空字串
窗体代代码rn[code=vb]rnPrivate Sub CmdfindWinEx_Click()rnLoadList GetWindowM(HwndA)‘参数 HwndA 传入一个窗口标题rnEnd SubrnPublic Function LoadList(ByRef ShowList() As String)'加载列表rnOn Error Resume NextrnDim i As IntegerrnFor i = LBound(ShowList) To UBound(ShowList)rnList1.AddItem ShowList(i)'测试窗体上有一个frame控件,上面有3文本框rn'frame控件,上面有3文本框,不能返回 ,返回空字串rnNextrnEnd Functionrn[/code]rn模块代码rn[code=vb]rnOption ExplicitrnPublic Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongrnPublic Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongrnPublic Declare Function GetWindow Lib "user32" (ByVal Hwnd As Long, ByVal wCmd As Long) As LongrnPublic Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal Hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongrnPublic Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal Hwnd As Long) As LongrnPublic Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal Hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As LongrnPublic Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Longrn'SendMessage发送字符串时,在声明Sendmessage时将Sendmessage的第四个参数改成ByVal lParam As Stringrn'Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongrnrnPublic Const WM_SETTEXT = &HCrnrnPublic Const GW_CHILD = 5rnPublic Const GW_HWNDFIRST = 0rnPublic Const GW_HWNDNEXT = 2rnPublic SaveHwnd() As Long ' 保存句柄标识符rnPublic SaveList() As StringrnPublic ClassName As String * 255rnPublic WinCaption As String * 255rnPublic Length As LongrnPublic Function GetWindowM(ByVal Hwnd As Long) As String() 'hwnd 父窗口句柄rnOn Error Resume NextrnStatic i As IntegerrnDim MidHwnd As Long '子窗口句柄rnDim SaveList() As StringrnIf i = 0 Then '如果i=0,则保存父窗口句柄及标题rn ReDim Preserve SaveList(i) As Stringrn ReDim Preserve SaveHwnd(i) As Longrn SaveHwnd(i) = Hwndrn SaveList(i) = GetString(Hwnd)rnEnd IfrnMidHwnd = GetWindow(Hwnd, GW_CHILD)rnIf (MidHwnd = 0) Then Exit FunctionrnMidHwnd = GetWindow(MidHwnd, GW_HWNDFIRST)rnIf (MidHwnd = 0) Then Exit FunctionrnWhile (MidHwnd <> 0)rni = i + 1rnReDim Preserve SaveList(i) As StringrnReDim Preserve SaveHwnd(i) As LongrnSaveHwnd(i) = MidHwndrnSaveList(i) = GetString(MidHwnd) '字串处理rnDebug.Print SaveList(i)'这里能正确返回三个文本框句柄和标题rn'Form1.List1.AddItem SaveList(i)rnrnGetWindowM (MidHwnd)rnMidHwnd = GetWindow(MidHwnd, GW_HWNDNEXT)rnWendrnGetWindowM = SaveListrnrnEnd Functionrn[/code]rn
Python爬虫定位标签时,返回空列表
a=html.xpath('//li[@class="j_thread_list clearfix"]')nnliTags = soup.find_all('li', attrs='class': ' j_thread_list clearfix')n用xpath和BeauSoup 抓取这个标签都跪了,结果都是返回一个空列表,这是怎么回事啊,困扰好久了nn特别是xpath,经常遇到爬取某个标签运行代码返回空列表,但是使用Chrome 的xpath helper 却能正常捕捉,并且有时候使用别人的原码也会出现这种情况,想知道是哪方面的原因,软件有问题?还是编程哪个细节漏了nn使用别人以前的原码也出现过这个问题,某个标签输出返回空列表,后面具体内容就抓不出来了。nnn打算的是,编个程序,爬取某个贴吧,前3页,把每个帖子(除置顶帖)的标题,作者,创建时间和链接爬取出来,返回成一个列表,里面的元素是每个帖子信息合成的一个字典n分别用 bs4 xpath,正则表达式做n结果做前两个都在定位那个标签时跪了,一直返回空列表nn路过的大佬,能详细解答一下吗?尽量从这类问题讲,不限于这个问题
POI读取excel返回空?
我用struts2 hibernate POI读取excel文件时,能够实现上传,并且获取了路径,但是返回excel文件数据为空,不知道为什么读取不到,谁遇到过帮我指点一下,先谢过啦~~
systools.admin_task_status 返回空
最近项目想使用DB2 的 ATS (Administrative task scheduler),使用存储过程创建定时task去完成一些工作rnrn比如说rnCALL SYSPROC.ADMIN_TASK_ADD (rn 'TEST 277',rn NULL,rn NULL,rn NULL,rn '51 20 * * *',rn 'TESTSCHEMA',rn 'TEST_UPDATE',rn NULL,rn NULL,rn NULLrn );rnrn之后能创建taskrnSELECT * from SYSTOOLS.ADMIN_TASK_LIST;rn可以看到task被创建了,但是到时并未执行rnrn而执行 SELECT * from SYSTOOLS.ADMIN_TASK_STATUS;rn也返回空,不知道为什么这样。rnrn请问哪天DB2大侠能够指点一下?十分感谢!!rnrn
SelectObject返回空的问题
[code=C/C++]rnvoid CBitmapDlg::OnPaint()rnrnrn CPaintDC dc(this);rn rn rn rnrn CDC cdc;rn int i = cdc.CreateDC(L"DISPLAY", NULL, NULL, NULL);rn rn CBitmap c,ccc;rn c.CreateCompatibleBitmap(&cdc,100,100);rn cdc.SelectObject(&c);rn rnrnrnrn rn //cc->CreateCompatibleBitmap(&dc,100,100);rn HBITMAP hbitmap = (HBITMAP)cdc.SelectObject(&ccc);rnrn CBitmap* cc = CBitmap::FromHandle(hbitmap);rn ASSERT(cc!=NULL);//这里为什么总是失败呢?rn rn rn[/code]
aspping返回空
怎么回事?找了老半天,没有答案
CString::GetLength() 返回空
CString str;rnstr="abc";rnMessageBox((LPCTSTR)str.GetLength());rnrn为什么为空,取不到字符长度
LoadLibraryEx失败,返回空
我需要使用别公司的一个dll,我手上有他们整包程序,包括需要使用的dll以及他们调用dll的UI。rn但是我自己写的UI无法通过LoadLibraryEx去加载该Dll.rn他们的UI能正常在我的环境下开启,也就是正常load dll。这样应该可以排除系统环境的问题吧?rn请问这是他们UI有做特别的什么动作么?我写UI应该注意些什么么?
Fragment getArguments() 返回空
有一个Fragment其中有一个作为根布局的tabHost:rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrn创建和更新Fragment的代码:rnrn private void updateTab(String tabId, int placeholder) rn FragmentManager fm = getFragmentManager();rn if (fm.findFragmentByTag(tabId) == null) rn Bundle arguments = new Bundle();rn arguments.putInt("current_day", mCurrentTab);rn EpgEventListFragment fragment = new EpgEventListFragment();rn fragment.setArguments(arguments);rn rn fm.beginTransaction()rn .replace(placeholder, new EpgEventListFragment(), tabId)rn .commit();rn rn rnrn在`EpgEventListFragment`的`onCreate(...)`方法中,我在获取参数Bunble的时候总是得到null:rnrn @Overridern public void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn rn Bundle arguments = getArguments();rn if (arguments == null)rn Toast.makeText(getActivity(), "Arguments is NULL", Toast.LENGTH_LONG).show();rn elsern mCurrentDay = getArguments().getInt("current_day", 0);rn rn ...rn rnrn不知道问题在哪?rnrn我还试过在`onAttach(...)`中获取`getArguments()`,但是结果都一样,返回null。rnrn请各位大侠帮忙解决一下哦。rnrn
GetMeun返回空
我想在菜单项的前面加上一个位图,我看了一个例子,是应该这样rnrnvoid CRoadPhotographerView::OnDraw(CDC* /*pDC*/)rnrn // TODO: 在此添加专用代码和/或调用基类rn rn CWnd *pParent=GetParent();rnrn CMenu *pMenuBar=pParent->GetMenu();rn CMenu *pMenu=pMenuBar->GetSubMenu(0);rnrn pMenu->SetMenuItemBitmaps(0, MF_BYPOSITION, &m_bmHelp, &m_bmHelp);rnrnrn可是运行的时候程序老是崩溃,debug了一下发现是GetMenu返回了一个空值,我把GetParent换成 afxGetMainWnd也不行, getmenu仍然返回空值, 我查了一下,这种作法在vc6下面是没有问题的, 但是在vc7.1下面就是我这个问题,那位大侠指点一下该怎么解决阿,多谢了。
Solr高亮返回空
solr在用了join查询之后,设置高亮无效,返回空rn[img=https://img-bbs.csdn.net/upload/201711/19/1511091283_389690.png][/img]rnrnrn!join from=realId to=realId fromIndex=personnel_file_data( content:哈哈哈哈 OR abstrace:哈哈哈哈 OR title:哈哈哈哈 OR keywords:哈哈哈哈 OR tags:哈哈哈哈 )
返回空List的方式
方式一:new ArrayList()  JDK1.8已经优化了,默认构造函数创建的list内部共享空数组,首次插入数据时才会扩容到默认容量; private static final Object[] DEFAULTCAPACITY_EMPTY_ELEMENTDATA = {}; public ArrayList() { this.elementData = DEFAULTCAP...
MemeberShip.GetUser() 总是返回空
登陆的时候Membership.ValidateUser 已经验证成功了,并且确定登陆用户在Membership 表里面,但是GetUser总是返回空rnrnrn站点有两个登陆页面一个是后台的 ,一个是前台的,网上查说一定要配置成form验证的,我的webconfig已经配置成forms验证了,只是里面只配置了后台的登陆页面(如下) 没有配置前台的登陆页,会是这个影响的吗?其它的还有什么原因呢?rnrn(membership 的配置节点中也配置了applicationname了,网上有说这个原因的)rnrnrn rn rn rnrn
ImageIO.read返回空
javax.imageio.ImageIO.read返回空rn普通图片没问题,但是有个图片大小为1.17 MB,结果就返回NULL了。rn怎么解决啊。
finder.GetFileName()返回空
CFileFind finder;rnBOOL bWorking = finder.FindFile("C:\\Documents and Settings\\admin\\桌面\\aaa\\ccc\\ddd\\*.*");rnif (!bWorking)rnrn AfxMessageBox("not found");rnrnwhile (bWorking) rnAfxMessageBox("filename:"+finder.GetFileName());rn if (finder.IsDots())rn continue;rn CString tmpfilepath; rn tmpfilepath = finder.GetFileName();// GetFilePath();rnAfxMessageBox("tmpfilepath:"+tmpfilepath);rn if (tmpfilepath.IsEmpty())rn rn AfxMessageBox("IsEmpty");rn continue;rn rn。。。。。。。。。。rn。。。。。。。。。rnrn遍历查文件,能进去,但是所有的finder.GetFileName()返回的都是空字符串,getfiletitle也是,getfilepath能得到路径,也没文件名,我怎么都发现不了异常,是怎么回事啊?
如何返回空数组?
假设函数为CTest[] getTest()rn如何返回空的数组呢rnrnreturn null不是数组rnreturn ; 报错rnreturn (CTest);报错rnrnrnrn我现在用下面的办法,有没有一步到位的??rnCTest objReturn[]=;rnreturn objReturn ; rnrnrnrn
Win32下 GetDlgItem返回空
HWND GetDlgItem( rn HWND hDlg, rn int nIDDlgItemrn); rnParametersrnhDlg rn[in] Handle to the dialog box that contains the control. rnnIDDlgItem rn[in] Specifies the identifier of the control to be retrieved. rn我现在在VS2005下的移动设备里用Win32编程,想试试看图片控件,来响应单击消息。但是无法活动该picture control的句柄。不知道怎么用,希望高手指点迷津:rn[color=#99CC00]// “About”框的消息处理程序。由主窗口程序点击“About”菜单响应的对话框的处理过程[/color]rnINT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)rnrn switch (message)rn rnrn case WM_INITDIALOG:rn rn // 创建一个“完成”按钮并调整其大小。rn SHINITDLGINFO shidi;rn shidi.dwMask = SHIDIM_FLAGS;rn shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN | SHIDIF_EMPTYMENU;rn shidi.hDlg = hDlg;rn SHInitDialog(&shidi);rn rn return (INT_PTR)TRUE;rnrn case WM_COMMAND:rn if (LOWORD(wParam) == IDOK)rn rn EndDialog(hDlg, LOWORD(wParam));rn return TRUE;rn rn break;rn[color=#339966]//自己添加的响应左键消息[/color]rn case WM_LBUTTONDOWN:rn RECT rect;rn POINT point;rn HWND hButton;rn hButton = GetDlgItem(hDlg,IDC_Photo);[color=#339966]//“IDC_Photo”是我在“IDD_ABOUTBOX”对话框上事先已经添加上去的一个PICTURE CONTROL控件[/color][color=#339966]的ID号[/color]rn if(NULL == hButton)rn rn MessageBox(NULL, _T("hButton = NULL"), _T("命令"), MB_OK);rn LPVOID lpMsgBuf; rn FormatMessage( rn FORMAT_MESSAGE_ALLOCATE_BUFFER | rn FORMAT_MESSAGE_FROM_SYSTEM | rn FORMAT_MESSAGE_IGNORE_INSERTS, rn NULL, rn GetLastError(), rn 0, // Default language rn (LPTSTR)&lpMsgBuf, rn 0, rn NULL); rnrn MessageBox(NULL, (LPCTSTR)lpMsgBuf, _T("命令"), MB_OK | MB_ICONINFORMATION); rn // Free the buffer. rn LocalFree(lpMsgBuf);rn rn if(FALSE == GetWindowRect(hButton,&rect))rn rn MessageBox(NULL, _T("GetWindowRect(hButton,&rect)) = FALSE"), _T("命令"), MB_OK); rn rn rn GetCursorPos(&point);rnrn if(PtInRect(&rect,point)) rn rn MessageBox(NULL, _T("在本示范程序中,该命令的功能暂时缺省。"), _T("命令"), MB_OK); rn rn break;rnrn case WM_CLOSE:rn EndDialog(hDlg, message);rn return TRUE;rnrn#ifdef _DEVICE_RESOLUTION_AWARErn case WM_SIZE:rn rn DRA::RelayoutDialog(rn g_hInst, rn hDlg, rn DRA::GetDisplayMode() != DRA::Portrait ? MAKEINTRESOURCE(IDD_ABOUTBOX_WIDE) : MAKEINTRESOURCE(IDD_ABOUTBOX));rn rn break;rn#endifrn rn return (INT_PTR)FALSE;rnrnrnrn问题:为什么我在About对话框上随便的哪里单击都会弹出“hButton = NULL”呢?然后GetLastError()显示:此函数仅在Win32模式下有效。
getHibernateTemplate返回空?为什么
刚学spring,非web项目,我用MyEclipse生成,写了个JUnit,最后说getHibernateTemplate为空为什么?
LoadImage()返回空
m_bmpHandle.DeleteObject();rnHBITMAP hbmp = (HBITMAP)::LoadImage(NULL, strBmpPath, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE | LR_CREATEDIBSECTION);rnDWORD dwError = GetLastError();rnBOOL bRes = m_bmpHandle.Attach(hbmp);rnrndwError返回的是零,说明LoadImage()执行成功了,但是LoadImage()实际返回的是空,strBmpPath传得是绝对路径,而且对照过了,是对的,位图是通过海康的SDK来抓取的
为什么返回空记录?
表receive中dtmreceive为datatime 字段,查询其值为当天的记录,sql语句语句如下:rnselect * from receive WHERE convert(varchar(10),dtmreceive,120) = convert(varchar(10),getdate(),120)rn为什么返回记录为空?
responseXML返回空的问题
兄弟们,我想用XmlHttpRequest 从服务器端的数据里取数据,然后转成xml格式的数据发回客户端。但oReq.responseXML返回为空,oReq.responseText里是xml的数据。我想直接利用oReq.responseXML的返回对象解析xml数据。不清楚为什么,网上的很多方法都试过了,不行。后来,我发现oReq.responseText返回的内容里不光有xml数据,还有Default.aspx的页面内容。可是我 Response.Write(xmlData.ToLower()) 只是数据,怎么会把default.aspx页面的内容也传回来了?这是不是oReq.responseXML返回为空的原因呢?请大家指教!rn客户端代码:rn rn服务器端代码:rn rn ......rn // ds 是查询数据苦后返回的DataSetrn string xmlData = ds.GetXml();rn Response.ContentType = "text/xml";rn Response.Charset = "utf-8";rn Response.Write(xmlData.ToLower());rn rnrn
GetProcAddress 返回空问题
dll unicode编码rn生成的dll,用dependencies打开可以看到名称为:rn?SetHook@@YG_NXZrnrn调用exe(unicode编码)用rnlproc = (LPSETHOOK)GetProcAddress((HMODULE)hDll,"SetHook"); rn不知为何总是返回空
C#返回空数组
return new List&amp;lt;LoadTaskViewModel&amp;gt;() {};return new 指定类型() {};return new int[]{};- - 懵逼到家了
php发送微博的update方法返回空
无法发送微博,没有报错,有谁做过这个的告知下,谢谢![img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/22.gif][/img]rn[code=php]update($mes);rnecho $weibo==null;rn?>[/code]
resty中redis返回空
resty中对于redis查询不存在的键,返回的空是USERDATA类型,需额外处理,转为boolean是true;
getHibernateTemplate().find返回空问题
ssh中getHibernateTemplate().find返回空能同时导入cglib-nodep-2.1.3.jar和cglib2.2.jar吗?rn导完包以后配置文件还要做什么修改
MAKEINTRESOURCE() gdi+ 出错,返回空
在VC8中,我用了:rnrnUSES_CONVERSION;rnBitmap * m_bmpSurface = Bitmap::FromResource( AfxGetApp()->m_hInstance, A2W((LPCSTR)MAKEINTRESOURCE(IDB_BITMAP1)));rn//???????????rnif(!m_bmpSurface) rn AfxMessageBox(_T("fail to load bitmap"));rn return;rnrn跟踪程序后;rnrn程序进入到函数:rninline LPWSTR WINAPI AtlA2WHelper(__out_ecount(nChars) LPWSTR lpw, __in LPCSTR lpa, __in int nChars, __in UINT acp) throw()rnrn ATLASSERT(lpa != NULL);rn ATLASSERT(lpw != NULL);rn if (lpw == NULL || lpa == NULL)rn return NULL;rn // verify that no illegal character presentrn // since lpw was allocated based on the size of lparn // don't worry about the number of charsrn lpw[0] = '\0';rn??????????int ret = MultiByteToWideChar(acp, 0, lpa, -1, lpw, nChars);rn if(ret == 0)rn rn ATLASSERT(FALSE);rn return NULL;rn rn return lpw;rnrn其中:lpa为空,从而产生错误rn请教,怎么解决; 谢谢
为什么CreateWindow返回空啊~
[code=C/C++][/code]#include rnrnTCHAR szTitle[100] = _T("GE"); // The title bar textrnTCHAR szWindowClass[500]=_T("GGG"); // the main window class namernLRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);rnint APIENTRY _tWinMain(HINSTANCE hInstance,rn HINSTANCE hPrevInstance,rn LPTSTR lpCmdLine,rn int nCmdShow)rnrn WNDCLASSEX wcex;rnrn wcex.cbSize = sizeof(WNDCLASSEX);rnrn wcex.style = CS_HREDRAW | CS_VREDRAW;rn wcex.lpfnWndProc = WndProc;rn wcex.cbClsExtra = 0;rn wcex.cbWndExtra = 0;rn wcex.hInstance = hInstance;rn wcex.hIcon = NULL;rn wcex.hCursor = NULL;rn wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);rn wcex.lpszMenuName = NULL;rn wcex.lpszClassName = szWindowClass;rn wcex.hIconSm = NULL;rnrn ATOM S = RegisterClassEx(&wcex);rnrn HWND hWnd = CreateWindow( szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,rn CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);rnrn if (!hWnd)rn rn return FALSE;rn rnrn ShowWindow(hWnd, nCmdShow);rn UpdateWindow(hWnd);rnrn return TRUE;rnrnrnLRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)rnrn return 0;rn //return DefWindowProc(hWnd, message, wParam, lParam);rn[code=C/C++][/code]
相关热词 c#串口测试应用程序 c# 匹配 正则表达式 c#防止窗体重绘 c#读写txt文件 c#挖地雷源代码 c#弹框选项 c# 移除 队列 c# 密码写入配置文件 c# 获取可用内存大小 c# 嵌入excel编辑