会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132441个问题

/**
 * 第二周第三天作業:打印出实心 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) {

        int count01=0;
        for (int i = 1; i <= 10; i++) {  //打印輸出10行*
            for (int a = 1; a <= 10; a++) {  //每行有10個*
                System.out.print("*");
                count01++;
                if (count01 % 10 == 0)// 换行
                    System.out.println();
            }
        }
        System.out.println("開始打印实心 10*10 正方形:");
        System.out.println();
        for (int i= 1; i <= 10; i++) {
            for (int a = 1; a <= 10; a++) {
                if (i == 1 || i == 10) {
                    System.out.print("* ");
                    } else {
                       if (a == 1 || a == 10) {
                          System.out.print("* " );
                        } else {
                          System.out.print(" ");
                     }

                }
            }
            System.out.println();

        }
        System.out.println("開始打印空心 10*10 正方形:");
    }
}

老师做作业10*10输出空心正方形碰到如下错误,求解答,已认真核对了好几次代码没找到错误。

运行图片如下QQ截图20200307105745.png

JAVA 全系列/第一阶段:JAVA 快速入门/控制语句、方法、递归算法 33976楼
Python 全系列/第一阶段:Python入门/函数和内存分析 33978楼
JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Dubbo 33979楼
JAVA 全系列/(旧的隐藏)第十五阶段:百战商城项目(Spring Cloud最新架构)/百战商城项目 33982楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程和并发编程(旧) 33983楼
Python 全系列/第一阶段:Python入门/控制语句 33985楼

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初级 33986楼
JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Maven 33987楼

老师,这是我爬取京东联盟的源码,由于爬取所有的商品信息,例如牙膏有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 爬虫开发/动态数据抓取 33988楼
Python 全系列/第一阶段:Python入门/函数和内存分析 33989楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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