会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132838个问题
Python 全系列/第一阶段:Python入门/控制语句 33977楼

C:\Windows\system32>workon django_env

(django_env) C:\Windows\System32>pip install mysqlclient

Collecting mysqlclient

  Using cached mysqlclient-1.4.6.tar.gz (85 kB)

Building wheels for collected packages: mysqlclient

  Building wheel for mysqlclient (setup.py) ... error

  ERROR: Command errored out with exit status 1:

   command: 'D:\python_env\django_env\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Jace\\AppData\\Local\\Temp\\pip-install-v7ymmrjl\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Jace\\AppData\\Local\\Temp\\pip-install-v7ymmrjl\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Jace\AppData\Local\Temp\pip-wheel-qh9stb47'

       cwd: C:\Users\Jace\AppData\Local\Temp\pip-install-v7ymmrjl\mysqlclient\

  Complete output (30 lines):

  running bdist_wheel

  running build

  running build_py

  creating build

  creating build\lib.win32-3.8

  creating build\lib.win32-3.8\MySQLdb

  copying MySQLdb\__init__.py -> build\lib.win32-3.8\MySQLdb

  copying MySQLdb\_exceptions.py -> build\lib.win32-3.8\MySQLdb

  copying MySQLdb\compat.py -> build\lib.win32-3.8\MySQLdb

  copying MySQLdb\connections.py -> build\lib.win32-3.8\MySQLdb

  copying MySQLdb\converters.py -> build\lib.win32-3.8\MySQLdb

  copying MySQLdb\cursors.py -> build\lib.win32-3.8\MySQLdb

  copying MySQLdb\release.py -> build\lib.win32-3.8\MySQLdb

  copying MySQLdb\times.py -> build\lib.win32-3.8\MySQLdb

  creating build\lib.win32-3.8\MySQLdb\constants

  copying MySQLdb\constants\__init__.py -> build\lib.win32-3.8\MySQLdb\constants

  copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.8\MySQLdb\constants

  copying MySQLdb\constants\CR.py -> build\lib.win32-3.8\MySQLdb\constants

  copying MySQLdb\constants\ER.py -> build\lib.win32-3.8\MySQLdb\constants

  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.8\MySQLdb\constants

  copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.8\MySQLdb\constants

  running build_ext

  building 'MySQLdb._mysql' extension

  creating build\temp.win32-3.8

  creating build\temp.win32-3.8\Release

  creating build\temp.win32-3.8\Release\MySQLdb

  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -ID:\python_env\django_env\include -Id:\python3.8.2\include -Id:\python3.8.2\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.8\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS

  _mysql.c

  MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory

  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

  ----------------------------------------

  ERROR: Failed building wheel for mysqlclient

  Running setup.py clean for mysqlclient

Failed to build mysqlclient

Installing collected packages: mysqlclient

    Running setup.py install for mysqlclient ... error

    ERROR: Command errored out with exit status 1:

     command: 'D:\python_env\django_env\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Jace\\AppData\\Local\\Temp\\pip-install-v7ymmrjl\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Jace\\AppData\\Local\\Temp\\pip-install-v7ymmrjl\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Jace\AppData\Local\Temp\pip-record-c_7pdi53\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\python_env\django_env\include\site\python3.8\mysqlclient'

         cwd: C:\Users\Jace\AppData\Local\Temp\pip-install-v7ymmrjl\mysqlclient\

    Complete output (30 lines):

    running install

    running build

    running build_py

    creating build

    creating build\lib.win32-3.8

    creating build\lib.win32-3.8\MySQLdb

    copying MySQLdb\__init__.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\_exceptions.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\compat.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\connections.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\converters.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\cursors.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\release.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\times.py -> build\lib.win32-3.8\MySQLdb

    creating build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\CR.py -> build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\ER.py -> build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.8\MySQLdb\constants

    running build_ext

    building 'MySQLdb._mysql' extension

    creating build\temp.win32-3.8

    creating build\temp.win32-3.8\Release

    creating build\temp.win32-3.8\Release\MySQLdb

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -ID:\python_env\django_env\include -Id:\python3.8.2\include -Id:\python3.8.2\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.8\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS

    _mysql.c

    MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory

    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

    ----------------------------------------

ERROR: Command errored out with exit status 1: 'D:\python_env\django_env\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Jace\\AppData\\Local\\Temp\\pip-install-v7ymmrjl\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Jace\\AppData\\Local\\Temp\\pip-install-v7ymmrjl\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Jace\AppData\Local\Temp\pip-record-c_7pdi53\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\python_env\django_env\include\site\python3.8\mysqlclient' Check the logs for full command output.




安装mysqlclient报错

Python 全系列/第十二阶段:Python_Django3框架/Django初级 33978楼
JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Maven 33979楼

老师,这是我爬取京东联盟的源码,由于爬取所有的商品信息,例如牙膏有23749这是理论数据值,

理论数据量.png但是实际爬取发现,当爬取到9500条时数据便替换成了其他的数据,如下图,但是我换了另外一个ip进行测试,发现当我从96页开始请求(一页一百条数据),同样也不是牙膏的商品数据,不知道到到底是理论数据不对的问题,还是遭遇了特别的反爬虫,只有牙膏和牙刷数据不对,其他的数据是没有问题(总共有五种商品),具体信息看附件

牙膏1.png然后面试跟我反馈有以下几点问题:

  1. 说我的爬取没有使用价格区分(这里没有理解他的意思)

  2. 牙膏和牙刷数据不全(这里就是上面的那个问题)

  3. 爬取的逻辑不对


解决方法我只能针对第三个问题进行改进,如采用scrapy-redis进行爬取,效率更高,由于没有form_data表单中的searchUUID没有更改(可能是这被反爬了),所以可以更改searchUUID,但是这些理论上只是不完美,逻辑问题上想不出其他的问题。

恳请老师指点!谢谢!

口腔护理.txt

漱口水.txt

牙膏2.txt

牙膏.txt

牙线棒.txt

牙刷.txt

requests
json
time

url=headers={
: ,
: ,
: ,
: ,
:,
:,
:,
:,
:,
:,
:,
:,
:,
:,
:,
:,
}
cat3ids=[,,,,]name={
    :,
    :,
    :,
    :,
    :}
proxy=[,
,
,
,
,
,
,
,
,
]
cat3id cat3ids:
    (.format(name[(cat3id)]))
    payload_data={:,:,:,:{:,:,:cat3id,:,:,:,:,:,:,:,:,:,:}}
    resp=requests.post(url,=json.dumps(payload_data),=headers,={:proxy[]})
    totalCount=resp.json()[][][]f=(.format(name[(cat3id)]),,=)
    i (totalCount//):
        (.format(i+))  payload_data1 = {: i+, : , : ,
                        : {: , : , : cat3id, : ,
                                 : , : , : , : , : , : ,
                                 : , : , : }}
        resp = requests.post(url, =json.dumps(payload_data1), =headers,={:proxy[]})
        contents=resp.json()[][]
        content contents:
            skuname=content[][]
            count=content[][]
            f.write(.format(,,name[(cat3id)],skuname,count))

        time.sleep()
()
    time.sleep()
    payload_data2 = {: (totalCount//)+, : totalCount%, : ,
                     : {: , : , : cat3id, : ,
                              : , : , : , : , : , : ,
                              : , : , : }}
    resp = requests.post(url, =json.dumps(payload_data2), =headers,={:proxy[]})
    contents2 = resp.json()[][]
    content2 contents2:
        skuname2 = content2[][]
        count2 = content2[][]
        f.write(.format(, , name[(cat3id)], skuname2, count2))
    f.close()


Python 全系列/第十四阶段:Python 爬虫开发/动态数据抓取 33980楼
Python 全系列/第一阶段:Python入门/函数和内存分析 33981楼
Python 全系列/下架-第十二阶段:Python_大型电商项目(5天后下架)/Django项目阶段-电商项目(旧) 33986楼
JAVA 全系列/第一阶段:JAVA 快速入门/面向对象详解和JVM底层内存分析 33987楼

老师你好我做作业打印10*10实心和空心正方形时,不知道空心正方形代码怎么才对麻烦指导:

/**
 * 第二周第三天作業:打印出实心 10*10 正方形、空心 10*10 正方形
 * * Job:打印出实心 10*10 正方形、空心 10*10 正方形
 * Author:李刚
 * Date:2020-3-4
 *
 */

package com.bjsxt.week02;
//打印出实心 10*10 正方形

public class Test10_10 {
    public static void main(String[] args) {
        System.out.println("開始打印实心 10*10 正方形:");

        for (int i = 0; i < 10; i++) {  //打印輸出10行*
            for (int a = 0; a < 10; a++) {  //每行有10個*
                System.out.print("*" + "\t");
            }
            System.out.println();

        }
        System.out.println("開始打印空心 10*10 正方形:");
        for (int b = 1; b <= 10; b++) {
            for (int c = 1; c <= 10; c++) {
                if (b >= 2 || b >= 9) {
                    System.out.print(" ");
                     } else {
                         if (c ==1 || c == 10) {
                           System.out.print("* " );
                         } else {
                          System.out.println(" ");
                       }

                }


                System.out.println();

            }

        }
    }
}


JAVA 全系列/第一阶段:JAVA 快速入门/控制语句、方法、递归算法 33988楼

下面的代码目的是通过同步方法实现卖票,可是不同步,请老师指导是哪里出了问题,感谢感谢!

/**
 * 使用同步方法实现卖票
 */
class SalesThread2 implements Runnable{
    private   int ticket = 5;
    @Override
    public void run() {
        for (int i = 1; i < 10; i++) {
           this.saleTicket();
        }
        System.out.println("票卖完了");
    }
    private  synchronized void saleTicket(){
            if (ticket>0){
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+"卖出了第"+(ticket--)+"张票");
            }

    }
}


/**
 * 线程同步测试类,可以分别使用同步锁和同步方法两种方式实现
 */
public class ThreadTes4 {
    public static void main(String[] args) {
        //test1();
        test2();
    }

    /**
     * 使用同步锁实现卖票
     */
    public static void test1(){
        System.out.println("使用同步锁实现卖票");
        SalesThread1 s1 = new SalesThread1();
        SalesThread1 s2 = new SalesThread1();
        SalesThread1 s3 = new SalesThread1();
        Thread t1 = new Thread(s1, "窗口A");
        Thread t2 = new Thread(s1, "窗口B");
        Thread t3 = new Thread(s1, "窗口C");
        t1.start();
        t2.start();
        t3.start();
    }

    /**
     * 使用同步方法实现卖票
     */
    public static void test2(){
        System.out.println("使用同步方法实现卖票");
        SalesThread2 s1 = new SalesThread2();
        SalesThread2 s2 = new SalesThread2();
        SalesThread2 s3 = new SalesThread2();
        Thread t1 = new Thread(s1, "窗口A");
        Thread t2 = new Thread(s2, "窗口B");
        Thread t3 = new Thread(s3, "窗口C");
        t1.start();
        t2.start();
        t3.start();
    }

}



运行结果截图:

image.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程技术(旧) 33990楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637